Created
November 2, 2011 14:02
-
-
Save blanchak/1333710 to your computer and use it in GitHub Desktop.
Kill database running processes in SQL Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE master | |
print 'Kill running processes' | |
DECLARE @SQL VARCHAR(MAX) | |
SET @SQL = '' | |
SELECT @SQL = @SQL + 'Kill ' + CONVERT(VARCHAR, SPId) + ';' | |
FROM MASTER..SysProcesses | |
WHERE DBId = DB_ID('YOUR_DATABASE') AND SPId <> @@SPId | |
print @SQL | |
EXEC(@SQL) | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice job buddy!