To check blocking
select * from sys.sysprocesses where blocked <> 0
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
head blocker
++++++++++
declare @handle binary(20), @spid int
select top 1 @spid = blocked
from master..sysprocesses a
where a.blocked != 0
and a.blocked not in (select spid from master..sysprocesses b where blocked != 0)
if @spid is not null
begin
select @handle = sql_handle from master..sysprocesses where spid = @spid
exec sp_who2 @spid
dbcc inputbuffer (@spid)
select lastwaittype from sysprocesses where spid=@spid
select * from ::fn_get_sql(@handle)
end
No comments:
Post a Comment