Created
June 3, 2014 22:29
-
-
Save Greyeye/9cfe29ff7a10f67d2b62 to your computer and use it in GitHub Desktop.
To kill all conn before starting mirror (or drop database)
From http://stackoverflow.com/questions/7197574/script-to-kill-all-connections-to-a-database-more-than-restricted-user-rollback
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 @kill varchar(8000) = ''; | |
select @kill=@kill+'kill '+convert(varchar(5),spid)+';' | |
from master..sysprocesses | |
where dbid=db_id('MyDB'); | |
print @kill; | |
exec (@kill); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment