Kill Blocked Processes - SPIDs
Useful script to kill all blocked process.
select * from sysprocesses where blocked > 0 and spid <> blocked
declare @cmd nvarchar(800)
declare @spid int
AGAIN:
if exists (select null from sysprocesses where blocked > 0 and spid <> blocked)
begin
set @cmd = ”
set @spid = ”
select @spid = max(blocked) from sysprocesses where blocked > 0 and spid <> blocked
select @cmd = ‘kill ‘ + convert(nvarchar,@spid)
select @cmd
exec (@cmd)
end
if exists (select null from sysprocesses where blocked > 0) GOTO AGAIN
