Skip to content

Instantly share code, notes, and snippets.

@slabad
Created November 10, 2011 14:35
Show Gist options
  • Save slabad/1354977 to your computer and use it in GitHub Desktop.
Save slabad/1354977 to your computer and use it in GitHub Desktop.
TSQL: FindBlockingChain
select
SPID
,Status
,loginame
,HostName
,blocked
,open_tran
,waittype
,cmd
,Last_Batch
,text
,lastwaittype
,waitresource
,cpu
,physical_io
,t.dbid
,Program_Name
,hostprocess
,sql_handle
from sys.sysprocesses
CROSS APPLY sys.dm_exec_sql_text(sql_handle) t
WHERE SPID in (select Blocked from master..sysprocesses where cast(blocked as varchar(20)) <> ' .')
--and open_tran > 0
order by blocked
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment