То allow a user to change Read-Only flag of a DB

I have SQL Server 2012 Enterprise. I have an SQL user that is not sysadmin on the server. The user is allowed to read and write the DB; but it cannot change Read-Only flag (Database Properties -> Options -> Database Read-Only) of the DB. What should be done to allow the user to change Read-Only flag?

SQL Server 2012 is not supported anymore.

You will need the alter database right:

ALTER DATABASE SET Options (Transact-SQL) - SQL Server | Microsoft Learn

USE [YOUR_DB]
GO
GRANT ALTER TO your_user
GO
1 Like

The article is good; it contains what I need:

USE master;
GO
ALTER DATABASE [database_name]
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE;
GO
ALTER DATABASE [database_name]
SET READ_ONLY
GO
ALTER DATABASE [database_name]
SET MULTI_USER;
GO