[font=微软雅黑, "]1) sql语句:
[font=微软雅黑, "] WITH CTE_SID ( BSID, SID, sql_handle )[font=微软雅黑, "]
[font=微软雅黑, "] AS ( SELECT blocking_session_id ,
[font=微软雅黑, "] session_id ,
[font=微软雅黑, "] sql_handle
[font=微软雅黑, "] FROM sys.dm_exec_requests
[font=微软雅黑, "]
WHERE blocking_session_id <>
0
[font=微软雅黑, "] UNION ALL
[font=微软雅黑, "] SELECT A.blocking_session_id ,
[font=微软雅黑, "] A.session_id ,
[font=微软雅黑, "] A.sql_handle
[font=微软雅黑, "] FROM sys.dm_exec_requests A
[font=微软雅黑, "] JOIN CTE_SID B ON A.SESSION_ID = B.BSID
[font=微软雅黑, "] )
[font=微软雅黑, "] SELECT C.BSID ,
[font=微软雅黑, "] C.SID ,
[font=微软雅黑, "] S.login_name ,
[font=微软雅黑, "] S.host_name ,
[font=微软雅黑, "] S.status ,
[font=微软雅黑, "] S.cpu_time ,
[font=微软雅黑, "] S.memory_usage ,
[font=微软雅黑, "] S.last_request_start_time ,
[font=微软雅黑, "] S.last_request_end_time ,
[font=微软雅黑, "] S.logical_reads ,
[font=微软雅黑, "] S.row_count ,
[font=微软雅黑, "] q.text
[font=微软雅黑, "] FROM CTE_SID C
[font=微软雅黑, "] JOIN sys.dm_exec_sessions S ON C.sid = s.session_id
[font=微软雅黑, "] CROSS APPLY sys.dm_exec_sql_text(C.sql_handle) Q
[font=微软雅黑, "] ORDER BY sid
[font=微软雅黑, "]
2)
如果出现死锁或者堵塞现象,就会在执行结果中罗列出来
[font=微软雅黑, "]session id表示被阻塞的id
[font=微软雅黑, "]blocking_session_id 表示阻塞session id的id
[font=微软雅黑, "]
[font=微软雅黑, "]
[font=微软雅黑, "]
[font=微软雅黑, "]如果问题还存在,请联系
阿里云售后支持[font=微软雅黑, "]。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。