Created
September 4, 2015 13:14
-
-
Save tompazourek/6ccf9e6526e738c64a8e to your computer and use it in GitHub Desktop.
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] | |
DECLARE @dbname SYSNAME | |
SET @dbname = 'DATABASENAME' | |
DECLARE @spid INT | |
SELECT @spid = MIN([spid]) FROM [master].[dbo].[sysprocesses] WHERE [dbid] = DB_ID(@dbname) | |
WHILE @spid IS NOT NULL | |
BEGIN | |
EXECUTE ('KILL ' + @spid) | |
SELECT @spid = MIN(spid) FROM [master].[dbo].[sysprocesses] WHERE [dbid] = DB_ID(@dbname) AND [spid] > @spid | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment