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 run KILL 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 = 52 SET @sql = 'KILL ' + CAST(@spid AS VARCHAR) EXEC(@sql)