SQL Server 查询数据库中被锁定的表

在一次测试过程中,发现有些表一直被锁定,从网上搜集了下资料,可以使用一下语句查看数据库中那些表正被锁定:

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

  

原文地址:https://www.cnblogs.com/wanghao4023030/p/7510142.html