SQL Server - Set Single-User mode

Set database to SINGLE_USER mode do something and set MULTI_USER mode. Alter database mode using simple T-SQL statements.

Script source:

USE [master]
GO
ALTER DATABASE [] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO
-- do some magic here
GO
ALTER DATABASE [] SET MULTI_USER;
GO

Leave a Reply

Your email address will not be published. Required fields are marked *