post icon

Kill executing process on database

Ecco lo statement sql per eseguire il comando kill su tutti i processi in esecuazione su uno specifico database.

DECLARE @DatabaseName nvarchar(50) SET @DatabaseName = N'Northwind' DECLARE @STR_SQL nvarchar(max) SET @STR_SQL = '' SELECT @STR_SQL = @STR_SQL + 'Kill ' + Convert(varchar, SPId) + ';' FROM MASTER..SysProcesses WHERE DBId = DB_ID(@DatabaseName) AND SPId <> @@SPId EXEC(@STR_SQL)

Download source kill_all_processes_on_database.zip (344,00 bytes)

19 febbraio 2009 @ 19:00

No comments yet.

Leave a comment

Leave a Reply

Are you human? Time limit is exhausted. Please reload CAPTCHA.