Created
November 19, 2010 17:19
-
-
Save bigsan/706810 to your computer and use it in GitHub Desktop.
SQL: Kill processes related to some database
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
DECLARE @dbName nvarchar(max), @sql nvarchar(max) | |
SELECT @dbName = N'__DBNAME__', @sql = N'' | |
SELECT @sql = @sql + N'KILL ' + CONVERT(nvarchar(max), spid) + ';' | |
FROM master..sysprocesses | |
WHERE dbid = DB_ID(@dbName) | |
--EXEC sp_executesql @sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment