sql 死锁查看

Posted itclw

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 死锁查看相关的知识,希望对你有一定的参考价值。

--每秒死锁数量

SELECT  *
FROM    sys.dm_os_performance_counters
WHERE   counter_name LIKE ‘Number of Deadlocksc%‘;

--查询当前阻塞

WITH    CTE_SID ( BSID, SID, sql_handle )
          AS ( SELECT   blocking_session_id ,
                        session_id ,
                        sql_handle
               FROM     sys.dm_exec_requests
               WHERE    blocking_session_id <> 0
               UNION ALL
               SELECT   A.blocking_session_id ,
                        A.session_id ,
                        A.sql_handle
               FROM     sys.dm_exec_requests A
                        JOIN CTE_SID B ON A.SESSION_ID = B.BSID
             )
    SELECT  C.BSID ,
            C.SID ,
            S.login_name ,
            S.host_name ,
            S.status ,
            S.cpu_time ,
            S.memory_usage ,
            S.last_request_start_time ,
            S.last_request_end_time ,
            S.logical_reads ,
            S.row_count ,
            q.text
    FROM    CTE_SID C 
            JOIN sys.dm_exec_sessions S ON C.sid = s.session_id
            CROSS APPLY sys.dm_exec_sql_text(C.sql_handle) Q
    ORDER BY sid

以上是关于sql 死锁查看的主要内容,如果未能解决你的问题,请参考以下文章

sql 死锁查看

sql server 查看表的死锁和Kill 死锁进程

sql server 查看表的死锁和Kill 死锁进程

sql server 查看表的死锁和Kill 死锁进程

如何查看Sql Server 死锁报告?

SQLServer 2008数据库查看死锁堵塞的SQL语句