Bookmark and Share
Change a SQL DB to read-only / read-write
(Publish Date: 2014-5-29 11:29am, Total Visits: 576, Today: 1, This Week: 2, This Month: 2)

-- Make Database Read Only

USE [master]
GO
ALTER DATABASE [DBNAME] SET READ_ONLY WITH NO_WAIT
GO

-- Make Database Read/Write


USE [master]
GO
ALTER DATABASE [DBNAME] SET READ_WRITE WITH NO_WAIT
GO

-- Make Database in SINGLE_USER

USE master;
GO
ALTER DATABASE [DBNAME]
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE;
GO