How to put a database into Single User Mode with T-SQL

You can easily put a database into or take it out of single user mode with the following T-SQL:

 
ALTER DATABASE  [MyDatabase] SET SINGLE_USER WITH NO_WAIT
GO
 
ALTER DATABASE  [MyDatabase] SET MULTI_USER WITH NO_WAIT
GO
This entry was posted in MS SQL Server. Bookmark the permalink.

Leave a Reply

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