SQL检查锁&解锁

use master  
go  
  
--检索死锁进程  
select spid, blocked, loginame, last_batch, status, cmd, hostname, program_name  
from sysprocesses  
where spid in  
( select blocked from sysprocesses where blocked <> 0 ) or (blocked <>0)

--检索死锁进程
select request_session_id,OBJECT_NAME(resource_associated_entity_id) tableName from   
sys.dm_tran_locks  
where resource_type='OBJECT'  
 
kill 92

 

select er.session_id, CAST(csql.text AS varchar(255)) AS CallingSQL
from master.sys.dm_exec_requests er WITH (NOLOCK)
CROSS APPLY fn_get_sql (er.sql_handle) csql
where er.session_id =92

 

posted @ 2016-08-09 16:23  --宁静以致远--  阅读(512)  评论(0编辑  收藏  举报