Created
May 8, 2018 15:25
-
-
Save sayham-sjb/1371e6660dca8f0713bc5fbae2780203 to your computer and use it in GitHub Desktop.
Remove Single User Mode #sql
This file contains hidden or 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 | |
GO | |
DECLARE @kill varchar(max) = ''; | |
SELECT @kill = @kill + 'KILL ' + CONVERT(varchar(10), spid) + '; ' | |
FROM master..sysprocesses | |
WHERE spid > 50 AND dbid = DB_ID('DATABASENAME') | |
EXEC(@kill); | |
GO | |
SET DEADLOCK_PRIORITY HIGH | |
ALTER DATABASE {DATABASENAME} SET MULTI_USER WITH NO_WAIT | |
ALTER DATABASE {DATABASENAME} SET MULTI_USER WITH ROLLBACK IMMEDIATE | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment