Skip to content

Instantly share code, notes, and snippets.

@lpsm-dev
Last active December 27, 2021 22:25
Show Gist options
  • Save lpsm-dev/3b14b0104c24f5a837f7de4494bf654f to your computer and use it in GitHub Desktop.
Save lpsm-dev/3b14b0104c24f5a837f7de4494bf654f to your computer and use it in GitHub Desktop.
[Database] - Remove Single User in Database SQL Server ⚡
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
@lpsm-dev
Copy link
Author

Disable Single Mode

In this setup we create a simple SQL script that allows you disable single mode in SQL database. Enjoy 😄 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment