--查看被锁表:
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 = 109 --锁表进程
declare @sql varchar(1000)
set @sql='kill '+cast(@spid as varchar)
exec(@sql)
本文介绍了一种在SQL Server中查看被锁表的方法,并提供了具体的SQL语句来定位锁表进程。此外,还给出了通过KILL命令解锁特定会话ID的步骤,帮助数据库管理员快速解决锁表问题。
2178

被折叠的 条评论
为什么被折叠?



