Your write failed with Msg 3906. Check sys.databases.is_read_only for the named database and confirm you are on the intended instance before changing its access mode.
sys.databases.is_read_only. If this is a log-shipping secondary restored with STANDBY, read-only access may be intentional. Do not switch it to READ_WRITE until you confirm the database role and restore workflow.The exact Msg 3906 error
Check the database state
Run this on the instance named in the error and confirm the database you intended to write to:
SELECT name, state_desc, is_read_only
FROM sys.databases
WHERE name = N'YourDatabase';
If is_read_only is 1, SQL Server reports that database as read-only. If you expected writes, confirm the server, database name, and recovery or secondary role before changing anything.
This is the captured HPAI01 result after the disposable lab database was set to READ_ONLY. The failed update left its row unchanged.
If this is a log-shipping secondary
A secondary restored with STANDBY is available for read-only access between transaction-log restores. That read-only state is part of the restore workflow, not a cue to make the secondary writable. Confirm the log-shipping configuration and restore job before changing its state.
See Microsoft Docs: About log shipping.
If this database should accept writes
Only after confirming that this is the intended writable database, and not a log-shipping or other secondary, change its access mode:
ALTER DATABASE [YourDatabase] SET READ_WRITE;
Do not use this as a shortcut to clear the error on a secondary. The command changes the database state; it does not repair the wrong target or restore role.
See Microsoft Docs: ALTER DATABASE (Transact-SQL).
Frequently Asked Questions
Does Msg 3906 mean the SQL Server service account cannot write to the files?
Should I set a log-shipping secondary to READ_WRITE?
When is SET READ_WRITE appropriate?
Does Msg 3906 explain why the database is read-only?
Check the database’s role before changing its state.
- High Availability, for secondary databases and log-shipping operations.
- SQL Server Backup Failed or the Restore Is Stuck, if the read-only state followed a restore.
Leave a Reply