• Base en mode SINGLE_USER, que faire ?
Analyser les sessions bloquantes sur une BDD :

select d.name, d.dbid, spid, login_time, nt_domain, nt_username, loginame
 from sys.sysprocesses p inner join sys.sysdatabases d on p.dbid = d.dbid
 where d.name = 'testdb01'
 go

puis les killer ==> kill [SPID] ; go
  • Couper la replication d'objet sur une base
sp_removedbreplication 'DBName'
  • Suivre l'etat d'un backup ou d'un restore DB
SELECT r.session_id as SPID,
r.command as TASK,CONVERT(NUMERIC(6,2),
r.percent_complete) AS [%Complete],CONVERT(VARCHAR(20),DATEADD(ms,r.estimated_completion_time,GetDate()),20) 
AS [Estimation FINISH], CONVERT(NUMERIC(10,2),
r.total_elapsed_time/1000.0/60.0) AS [Elapsed Min], CONVERT(NUMERIC(10,2),
r.estimated_completion_time/1000.0/60.0) AS [TimeRemainingMin], CONVERT(NUMERIC(10,2),
r.estimated_completion_time/1000.0/60.0/60.0) AS [TimeRemainingHours], CONVERT(VARCHAR(1000),
(SELECT SUBSTRING(text,r.statement_start_offset/2, 
CASE WHEN r.statement_end_offset = -1 THEN 1000 ELSE (r.statement_end_offset-r.statement_start_offset)/2 END) 
FROM sys.dm_exec_sql_text(sql_handle))) AS COMMAND FROM sys.dm_exec_requests r 
WHERE command IN ('RESTORE DATABASE','BACKUP DATABASE')
  • Executer un script SQL
@XXXXX.sql
  • Executer un package SQL
EXEC "nom du package"