SELECT r.session_id, r.blocking_session_id, t.text AS [SQL Statement]
FROM sys.dm_exec_requests r
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) t
WHERE r.database_id=DB_ID('您的数据库名称') -- 数据库名
AND EXISTS (SELECT 1
FROM sys.dm_tran_locks l
WHERE l.request_session_id=r.session_id AND l.resource_type='OBJECT' AND l.resource_associated_entity_id=OBJECT_ID('您的表名') -- 表名
);
SQL Server 锁表 查看执行的语句
最新推荐文章于 2023-12-26 14:03:24 发布