Saturday, February 12, 2022

Switching SQL Server between Multi-User and Single User mode with a simple T-SQL

Recently had to manage database deployments where the SQL Server was hosted with a cloud solution provider of repute. The database was quite huge and hence during backup and restore had to switch the same to Single User mode. However the database was so huge that even after service refresh the right click properties on the database was not able to open because of resource contingency.

Hence I chose to have this switch done through simple T-SQL which I would like to share the same here for everyone’s benefit.

To Switch to Single User Mode:


use master
go
alter database [YourDatabaseName] set single_user with rollback immediate

 

To Return Back to Normal/Multi-User Mode:

use master
go
alter database [YourDatabaseName] set single_user with rollback immediate

Additionally there is one more argument called WITH NOWAIT which could be used if needed

No comments:

[Imported from Blogdrive]Online Virus Scanners

Online Virus Scanners Virus Scanners are no longer difficult to install, tedious to configure. There are easy to use Online Virus Scanne...