MSSQL READ_ONLY

Check

EXEC sp_dboption 'myDB', 'read only'

Change

To set a database to be READ ONLY...

ALTER DATABASE [myDB] SET READ_ONLY WITH NO_WAIT;

To set a database back to READ WRITE...

ALTER DATABASE [myDB] SET READ_WRITE WITH NO_WAIT;

NOTE: If any users are using the database you will get an error when attempting these changes. If you are unable to find a time where there are no users then consider forcing the users to disconnect by putting the database into single-user mode.

Make sure you understand the implications of doing this. i.e. you will be able to convert the database to READ ONLY/READ WRITE but what problems will you have caused for the connected users/applications?

ALTER DATABASE [myDB] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;

To revert to multi-user use...

ALTER DATABASE [myDB] SET MULTI_USER;