Set database to work in Single User or Multi User Mode

There are two ways :

EXEC sp_dboption 'pubs', 'single user', 'TRUE'
ALTER DATABASE pubs SET SINGLE_USER  WITH ROLLBACK IMMEDIATE

To deactive single user mode :

EXEC sp_dboption 'pubs', 'single user', 'FALSE'
ALTER DATABASE pubs SET MULTI_USER

Leave a Reply

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