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 *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>