Just Code‎ > ‎

TSQL - Set database to read only using single user mode

posted Jun 13, 2011, 4:56 AM by Peter Henell   [ updated Jul 5, 2011, 11:45 PM ]

Don't use this in production environment

ALTER DATABASE CustomerDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE

EXEC sp_dboption 'CustomerDB', 'read only', 'true'

ALTER DATABASE CustomerDB SET MULTI_USER
Comments