-- Script returns blocking information from the sysprocesses table
SELECT spid, blocked, status, waittime,
waittype, waitresource, db_name(dbid) DatabaseName, cmd,
hostname, loginame
FROM master..sysprocesses
WHERE blocked != 0
DECLARE @spid int
-- Get the root blocker's spid id
SELECT @spid = A.spid
FROM master..sysprocesses A
INNER JOIN master..sysprocesses B
ON A.spid = B.blocked
WHERE A.blocked = 0
IF NOT @spid IS NULL
BEGIN
-- Returns last statement sent from the connection
DBCC INPUTBUFFER(@spid)
END
blocking
最新推荐文章于 2024-09-26 11:53:27 发布