Last active
December 27, 2021 22:25
-
-
Save lpsm-dev/3b14b0104c24f5a837f7de4494bf654f to your computer and use it in GitHub Desktop.
[Database] - Remove Single User in Database 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 | |
GO | |
DECLARE @kill varchar(max) = ''; | |
SELECT @kill = @kill + 'KILL ' + CONVERT(varchar(10), spid) + '; ' | |
FROM master..sysprocesses | |
WHERE spid > 50 AND dbid = DB_ID('cadastro') | |
EXEC(@kill); | |
GO | |
SET DEADLOCK_PRIORITY HIGH | |
ALTER DATABASE [cadastro] SET MULTI_USER WITH NO_WAIT | |
ALTER DATABASE [cadastro] 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
Disable Single Mode
In this setup we create a simple SQL script that allows you disable single mode in SQL database. Enjoy 😄 !