TSQL - Set database to read only using single user mode

Post date: Jun 13, 2011 11:56:21 AM

Don't use this in production environment

ALTER DATABASE CustomerDB SET SINGLE_USER WITH ROLLBACK IMMEDIATEEXEC sp_dboption 'CustomerDB', 'read only', 'true'ALTER DATABASE CustomerDB SET MULTI_USER