22 August, 2013

Recovering SQL Server Database from Suspect Mode

Sometimes we have to face a critical situation when SQL Server database going to Suspect Mode. In that moment no work can be done on database. Database may go into suspect mode because the primary file group is damaged and the database cannot be recovered during the startup of the SQL Server

Reason for database to go into suspect mode:
1.    Data files or log files are corrupt.
2.    Database server was shut down improperly
3.    Lack of Disk Space
4.    SQL cannot complete a rollback or roll forward operation.

How to recover database from suspect mode:

1.    Change the status of your database. Suppose database name is “BluechipDB”
          EXEC sp_resetstatus '';
            Example: EXEC sp_resetstatus 'BlueChipDB'

2. Set the database in “Emergency” mode

ALTER DATABASE <Database Name> SET EMERGENCY;
Example: ALTER DATABASE BlueChipDB SET EMERGENCY

3. Check the database for any inconsistency

DBCC CHECKDB('');
Example: DBCC checkdb('BlueChipDB')

4. If you get any error after executing DBCC CHECKDB then immediately bring the database in SINGLE USER MODE by running following query. If no error found then you need not execute the following query.

ALTER DATABASE <Database Name> SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
Example: ALTER DATABASE BlueChipDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE

5. For safety, take the backup of the database.

6. Run the following query as next step. Remember while using the below query, that uses REPAIR_ALLOW_DATA_LOSS, is a one way operation that is once the database is repaired all the actions performed by these queries can’t be undone. There is no way to go back to the previous state of the database. So as a precautionary step you should take backup of your database in step 5 mentioned above.

DBCC CHECKDB ('', REPAIR_ALLOW_DATA_LOSS);
Example: DBCC CheckDB ('BlueChipDB', REPAIR_ALLOW_DATA_LOSS)



7. Finally, bring the database in MULTI USER mode

ALTER DATABASE <Database Name> SET MULTI_USER;

ALTER DATABASE [BlueChipDB]  SET MULTI_USER

8. Refresh your database server and verify the connectivity of your database. Now users should be able to connect to the database properly. If any data loss, you can restore database – backup taken in step 5.

9 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Recover SQL database from suspect mode is often a complicated one without using ant tool. In order to recover the SQL database with ease i recommend you to use the most successful Microsoft SQL database repair tool. This MDF recovery application software is highly developed with well established recovery algorithms. Learn how to recover SQL database from here: http://www.sqlrepairtool.org

    ReplyDelete
  3. sql database recovery is possible with the third party tool that i have used in my computer to recover sql data. There are so many feature also available in sql database recovery tool.

    ReplyDelete
  4. Now SQL users can easily recover SQL Server database from suspect mode and get back entire database of SQL MDF file by using SQL recovery tool: http://www.sqlrecoverysoftware.net/blog/repair-database-from-suspect-mode.html

    ReplyDelete
  5. I want share with you a best and effective way to repair and recover your SQL server with loss any data file. The software fix all the server errors and recover MDF file from you corrupt and damaged SQL server. Visit here: http://www.sqlrepair.org

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. Try RecoveryFix for SQL database recovery software to recover all deleted files from SQL server. This is very advance and good tool that helps you recover all missing file from SQL server. Download demo version from here: http://www.en.repairsqlserver.net

    ReplyDelete
  8. Hi Hasan,

    Thanks for sharing this tips!!!

    I want to share something about DBCC CHECKDB minimum repair options: repair_fast, repair_rebuilt & repair_allow_data_loss. Most of the users think minimum repair options are the last resort to recover database from suspect mode but it is not true. As you know, there is some amount of data loss in repair_allow_data_loss option. I recommend to try advanced sql database repair software to recover database from suspect mode if you don’t want to loss any data from database.

    http://www.mssqldatabaserecovery.com/

    Thanks
    Mark

    ReplyDelete
  9. I would like to suggest reliable and reasonable priced tool to recover all of your deleted SQL file from SQL server database. You can try this tool from here:-
    http://www.recoverfilesdata.com/sql-database-mdf-recovery.html/

    ReplyDelete