SqlServer查看锁表与解锁

--查看被锁表:

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

--spid 锁表进程
--tableName 被锁表名

--解锁:

declare @spid int
Set @spid = 75 --锁表进程
declare @sql varchar(1000)
set @sql='kill '+cast(@spid as varchar)
exec(@sql)

 

 转载:-----------------https://vip.kingdee.com/article/634407252463298560?productLineId=1&lang=zh-CN

posted @ 2024-11-20 17:52  九五小刘  阅读(53)  评论(0编辑  收藏  举报