CREATE TABLE #Result ( spid int, ecid int, status varchar(max), loginname varchar(max), hostname varchar(max), blk varchar(max), dbname varchar(max), cmd varchar(max), request_id int)INSERT #Result EXEC sp_who SELECT * FROM #Result WHERE dbname LIKE '%XXX%' DROP TABLE #Result -- Once you know the SPID you can runKILL 28 -- or whatever the SPID is
-- 查看锁情况SP_LOCK-- 通过 ObjId , 查看锁对象信息SELECT * FROM sysobjects WHERE id = '1131151075'-- 通过 spid, 解锁相应的线程DECLARE @spid INT DECLARE @sql VARCHAR(1000)SET @spid = 52SET @sql = 'KILL ' + CAST(@spid AS VARCHAR)EXEC(@sql)