declare @db_name varchar(100) = 'dbname';https://gist.github.com/szunyog/7941990
declare @kill_commands varchar(max) = '';
select
@kill_commands=@kill_commands+'kill '+convert(varchar(5),spid)+';'
from master..sysprocesses
where
spid <> @@SPID -- avoid to kill the current process
and dbid=db_id(@db_name)
print 'Executing: ' + @kill_commands;
exec (@kill_commands);
No comments:
Post a Comment