Sql Server 查看锁及解锁


--查看所有锁表
SELECT request_session_id spid, OBJECT_NAME(resource_associated_entity_id) tableName
FROM sys.dm_tran_locks
WHERE resource_type = 'OBJECT'
ORDER BY request_session_id , tablename ASC

--查看锁进程的具体信息
DBCC INPUTBUFFER (390)


--解锁
DECLARE @spid INT
SET @spid = 61--锁表进程
DECLARE @SQL VARCHAR (1000)
SET @SQL = 'kill ' + CAST (@spid AS VARCHAR) EXEC (@SQL)

posted @ 2022-05-18 15:41  LoveMe7788  阅读(563)  评论(0编辑  收藏  举报