码迷,mamicode.com
首页 > 数据库 > 详细

SQL死锁情况汇总排查

时间:2019-08-24 10:03:25      阅读:106      评论:0      收藏:0      [点我收藏+]

标签:when   ted   entity   left join   select   art   des   ssi   sso   

select dbname,entity_name,count(1) as locks from 
(SELECT request_session_id AS spid,  
       DB_NAME(resource_database_id) AS dbname,  
       CASE WHEN resource_type=‘object‘   
                 THEN OBJECT_NAME(resource_associated_entity_id)   
            WHEN resource_associated_entity_id=0 THEN ‘n/a‘  
            ELSE OBJECT_NAME(p.object_id) END AS entity_name,  
       index_id,  
       resource_type AS RESOURCE,  
       resource_description AS DESCRIPTION,  
       request_mode AS mode,  
       request_status AS STATUS   
FROM sys.dm_tran_locks t LEFT JOIN sys.partitions p ON p.partition_id=t.resource_associated_entity_id  
WHERE resource_database_id=DB_ID()) as a group by a.dbname,a.entity_name

  

SQL死锁情况汇总排查

标签:when   ted   entity   left join   select   art   des   ssi   sso   

原文地址:https://www.cnblogs.com/soleds/p/11403398.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!