--Make Database Read Only
USE [master]
GO
ALTER DATABASE [TESTDB] SET READ_ONLY WITH NO_WAIT
GO
--Make Database Read/Write
USE [master]
GO
ALTER DATABASE [TESTDB] SET READ_WRITE WITH NO_WAIT
GO
--If you face error that if database is already in use, you can resolve the same by making database in single user mode
--1. Set the database to single mode:
ALTER DATABASE [TESTDB] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
--2. Set the database to Multi-user mode
ALTER DATABASE [TESTDB]
SET MULTI_USER WITH ROLLBACK IMMEDIATE
Leave a Reply