zoukankan      html  css  js  c++  java
  • SQLServer 2008数据库查看死锁、堵塞的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
  • 相关阅读:
    康托(逆)展开(2015.8.6)
    高精度计算(2015.8.1)
    笔记(2015.8.1)
    筛法求素数(2015.7.30)
    欧几里德算法(2015.7.28)
    快速幂取模(2015.7.29)
    同余
    图论相关算法
    笔记(2015-07-24)
    ACM进阶计划
  • 原文地址:https://www.cnblogs.com/binlyzhuo/p/10244153.html
Copyright © 2011-2022 走看看