34,590
社区成员
发帖
与我相关
我的任务
分享
-- 修改一下,可以查看 dbo.A 表上详细的锁信息,以决定 kill 那个 request_session_id
select request_session_id,l.resource_type,l.resource_description,l.request_mode,l.request_type
from sys.dm_tran_locks l
where (resource_type='OBJECT' and resource_associated_entity_id=OBJECT_ID('dbo.A'))
or (resource_type in ('PAGE','KEY','EXTENT','RID','HOBT') and
OBJECT_ID('dbo.A')=(select [OBJECT_ID] from sys.partitions where hobt_id=l.resource_associated_entity_id));
-- 运行下面的语句获取锁定 dbo.A 表的 spid
select distinct request_session_id from sys.dm_tran_locks l
where (resource_type='OBJECT' and resource_associated_entity_id=OBJECT_ID('dbo.A'))
or (resource_type in ('PAGE','KEY','EXTENT','RID','HOBT') and
OBJECT_ID('dbo.A')=(select [OBJECT_ID] from sys.partitions where hobt_id=l.resource_associated_entity_id));