Here's an improved version which also reports the object ID and object name of the object(s) that a process is holding locks on. Much easier to find the problem :)Cheers-bCREATE PROCEDURE sp_lock4 ASset nocount onDECLARE @tSpids table(spid int PRIMARY KEY CLUSTERED (spid,objid), dbid int,objid int,count int)DECLARE @iSpid int,@dbID int,@objID int,@iCount int,@vcDBCC varchar(100),@vcName varchar(50) insert into @tSpids (spid,dbid,objid,count) select convert (smallint, req_spid) As spid, rsc_dbid, rsc_objid, count(*) as count from master.dbo.syslockinfo, master.dbo.spt_values v, master.dbo.spt_values x, master.dbo.spt_values u where master.dbo.syslockinfo.rsc_type = v.number and v.type = 'LR' and master.dbo.syslockinfo.req_status = x.number and x.type = 'LS' and master.dbo.syslockinfo.req_mode + 1 = u.number and u.type = 'L' group by converT(smallint,req_spid),rsc_dbid,rsc_objid having count(*)>10 order by count(*) descDECLARE cLoop cursor for select spid,dbid,objid,count from @tSpidsOPEN cLoopFETCH NEXT FROM cLoop INTO @iSpid,@dbID,@objID,@iCountWHILE @@FETCH_STATUS=0 BEGIN select @vcName=IsNull(name,'unknown') from sysobjects where id=cast(@objID as varchar(32)) select cast(@iSpid as varchar(4)) + ' has ' + cast(@iCount as varchar(5)) + ' locks on object ' + cast(@objid as varchar(20)) + ' (' + @vcName + ')' select @vcDBCC='dbcc inputbuffer(' + cast(@iSpid as varchar(5)) + ')' exec (@vcDBCC) FETCH NEXT FROM cLoop INTO @iSpid,@dbID,@objID,@iCount ENDCLOSE cLoopDEALLOCATE cLoop return (0) -- sp_lockGO