1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

Blocking Chain


Blocking Chain

Identify blocking chain processes and head of the blocking chain with wait types.

Select Session_ID,Blocking_Session_ID
 From Sys.dm_Exec_Requests
 Where Session_ID > 50
 And Blocking_Session_Id <> 0
SELECT
spid
,sp.STATUS
,loginame 
,hostname 
,blocked 
,open_tran
,dbname = SUBSTRING(DB_NAME(sp.dbid),1,50)
,cmd
,waittype
,waittime
,last_batch
,SQLStatement =
SUBSTRING
(
qt.text,
er.statement_start_offset/2,
(CASE WHEN er.statement_end_offset = -1
THEN LEN(CONVERT(nvarchar(MAX), qt.text)) * 2
ELSE er.statement_end_offset
END - er.statement_start_offset)/2
)
FROM master.dbo.sysprocesses sp
LEFT JOIN sys.dm_exec_requests er
ON er.session_id = sp.spid
OUTER APPLY sys.dm_exec_sql_text(er.sql_handle) AS qt
WHERE spid IN (SELECT blocked FROM master.dbo.sysprocesses)
AND blocked = 0

StoredProcs

SPID-SQLText

RowCounts

RenameDB

ClusterInfo

Backup-Restore

xp_cmdshell

Security

Indexes

Percentiles

Misc

Maintenance

Mirroring