当前位置:首页 > 开发 > 数据库 > 正文

在SQLSERVER中查找被阻塞和正在被阻塞的SQL

发表于: 2015-04-27   作者:357029540   来源:转载   浏览:
摘要: SELECT  R.session_id AS BlockedSessionID ,          S.session_id AS BlockingSessionID ,          Q1.text AS Block
SELECT  R.session_id AS BlockedSessionID , 
        S.session_id AS BlockingSessionID , 
        Q1.text AS BlockedSession_TSQL , 
        Q2.text AS BlockingSession_TSQL , 
        C1.most_recent_sql_handle AS BlockedSession_SQLHandle , 
        C2.most_recent_sql_handle AS BlockingSession_SQLHandle , 
        S.original_login_name AS BlockingSession_LoginName , 
        S.program_name AS BlockingSession_ApplicationName , 
        S.host_name AS BlockingSession_HostName 
FROM    sys.dm_exec_requests AS R 
        INNER JOIN sys.dm_exec_sessions AS S ON R.blocking_session_id = S.session_id 
        INNER JOIN sys.dm_exec_connections AS C1 ON R.session_id = C1.most_recent_session_id 
        INNER JOIN sys.dm_exec_connections AS C2 ON S.session_id = C2.most_recent_session_id 
        CROSS APPLY sys.dm_exec_sql_text(C1.most_recent_sql_handle) AS Q1 
        CROSS APPLY sys.dm_exec_sql_text(C2.most_recent_sql_handle) AS Q2

在SQLSERVER中查找被阻塞和正在被阻塞的SQL

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号