Thursday, November 19, 2009

Recovery of Read-only SQL DB

Login as sys admin, and run the following commands;
1. ALTER DATABASE SET EMERGENCY

2. ALTER DATABASE SET SINGLE_USER

3. ALTER checkdb(,REPAIR_ALLOW_DATA_LOSS) (The database should be restored from a backup made prior to the corruption, rather than repaired)
Note: This command checks the allocation, structural, logical integrity and errors of all the objects in the database. When you specify “REPAIR_ALLOW_DATA_LOSS” as an argument of the DBCC CheckDB command, the procedure will check and repair the reported errors. But these repairs can cause some data to be lost.
4. If the above script runs without any problems, you can bring your database back to the multi user mode by running the following SQL command:
ALTER DATABASE SET MULTI_USER

Blog Archive