Below script is used to change the database into single user mode. To kill the current connections change the database to single user mode then change it to single user mode.Replace the database name from MyDATABASE to the database name need to change to READ ONLY
USE [master]
GO
ALTER DATABASE [MyDATABASE] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
ALTER DATABASE [MyDATABASE] SET READ_ONLY WITH NO_WAIT
GO
ALTER DATABASE [MyDATABASE] SET MULTI_USER
GO
Below script is used to change the database into read/write user mode.
ALTER DATABASE [MyDATABASE] SET READ_WRITE WITH NO_WAIT
No comments:
Post a Comment