declare @sql varchar(100) while 1=1 begin select top 1 @sql = 'kill '+cast(spid as varchar(3)) from master..sysprocesses where spid > 50 and spid <> @@spid if @@rowcount = 0 break exec(@sql) end