How to kick out all user from SQL server database

There are a few ways to kick out the user from the database. I believe it works with most of SQL Server versions and editions.

ALTER DATABASE <Database name> SET SINGLE_USER WITH ROLLBACK IMMEDIATE
 GO
 USE <Database name>
 GO

Complete your task……

ALTER DATABASE <Database name> SET MULTI_USER
 GO

Some time need to wait for rallback existing transactions

Spread the love

Leave a Comment