sqlserver 表死锁处理
SELECT request_session_id as spid,
OBJECT_NAME(resource_associated_entity_id) AS tableName
FROM sys.dm_tran_locks WHERE resource_type = 'OBJECT'
DECLARE @spid INT;
SET @spid = 132;
DECLARE @sql VARCHAR(1000);
SET @sql = 'KILL '+ CAST(@spid AS VARCHAR);
EXEC (@sql);
error:
SELECT request_session_id as spid,
OBJECT_NAME(resource_associated_entity_id) AS tableName
FROM sys.dm_tran_locks WHERE resource_type = 'OBJECT'
DECLARE @spid INT;
SET @spid = 132;
DECLARE @sql VARCHAR(1000);
SET @sql = 'KILL '+ CAST(@spid AS VARCHAR);
EXEC (@sql);