USEGEAR

导航

sql server2005的死锁

select    
    request_session_id spid,   
    OBJECT_NAME(resource_associated_entity_id) tableName    
from    
    sys.dm_tran_locks   
where    
    resource_type='OBJECT' 


kill spid

每次服务激活时检查。有点蒙,是不是该这样。有什么好办法请告诉我。

测试做一个deadlock:

BEGIN TRANSACTION--开始事务

update   Sessions  set Created=GETDATE()  where sessionid='001'  WAITFOR DELAY '02:00'; 


select * from Sessions where sessionid='001'

select    
    request_session_id spid,   
    OBJECT_NAME(resource_associated_entity_id) tableName    
from    
    sys.dm_tran_locks   
where    
    resource_type='OBJECT' 
 

根据得到的spid进行kill

kill spid

 

posted on 2019-09-21 23:46  USEGEAR  阅读(145)  评论(0编辑  收藏  举报