MESLisnter select request_session_id spid, OBJECT_NAME(resource_associated_entity_id) tableName from sys.dm_tran_locks where resource_type='OBJECT' -- 解锁表 declare @spid int Set @spid = 95 --锁表进程 declare @sql varchar(1000) set @sql='kill '+cast(@spid as varchar) exec(@sql) sp_who2 exec sp_who2 dbcc inputbuffer(102) kill 102 dbcc inputbuffer(60)
select t1.resource_type [资源锁定类型] , DB_NAME(resource_database_id) as 数据库名 , t1.resource_associated_entity_id 锁定对象 , t1.request_mode as 等待者请求的锁定模式 , t1.request_session_id 等待者SID , t2.wait_duration_ms 等待时间 , (select TEXT from sys.dm_exec_requests r cross apply sys.dm_exec_sql_text(r.sql_handle) where r.session_id = t1.request_session_id) as 等待者要执行的SQL , t2.blocking_session_id [锁定者SID] , (select TEXT from sys.sysprocesses p cross apply sys.dm_exec_sql_text(p.sql_handle) where p.spid = t2.blocking_session_id ) 锁定者执行语句 from sys.dm_tran_locks t1, sys.dm_os_waiting_tasks t2 where t1.lock_owner_address = t2.resource_address
标签:dm,SQLSERVER,查询,sys,死锁,session,sql,t1,id From: https://www.cnblogs.com/LearningFromyou/p/17144303.html