Introduction
Some times you may get database error'Failed to update database because the database is read only' while inserting data into database or update the database, The reason is that your database might be in Warm-Stand by Mode or read only mode. The article describes how to recover database when the database is in Warm-Standby Mode.
Getting Started
When your database is in Warm-Standy Mode and to recover from this, first you need to move or change from current database(the database you want recover) connection to master database connection. Then you need to kill the database existing database (Current) user and then you have to restore the database.
After restoring the database, again you need to set the user of the database. Here bellow is the all the code syntax of SQL that recovers database from Warm-Standy Mode.
Killing Current Database User
ALERT DATABASE database-name SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
Complete Recovering Database
RESTORE DATABASE database-name WITH RECOVERY
Setting Database Users
ALERT DATABASE database-name SET MULTI_USER WITH ROLLBACK IMMEDIATE;
Related Articles
- Enable SQL Remote Connection
- Encrypt data across communication channels
- List Out Store Procedures That Executes Frequently
- Install certificate to enable encrypted connections to the Database Engine in SQL Server
- Create SQL Job in SQL Server 2017“
Summary
This article described the syntax, how to recover database from Warm-Standy Mode. I hope this article may help you.
Thanks