代码改变世界

查询当前死锁情况

2021-05-08 11:56  newbirth  阅读(46)  评论(0编辑  收藏  举报
SELECT ProcessType = 'Locked Process', 
      spid, 
      kpid, 
      a.blocked, 
      dbid, 
      uid, 
      loginame, 
      cpu, 
      login_time, 
      open_tran, 
      STATUS, 
      hostname, 
      program_name, 
      hostprocess, 
      nt_domain, 
      net_address, 
      s1 = a.spid, 
      s2 = 0
FROM     master..sysprocesses a
        JOIN
(
    SELECT blocked
    FROM   master..sysprocesses
    GROUP BY blocked
) b
            ON a.spid = b.blocked
WHERE   a.blocked = 0