Product Navigation

Recover & Repair SQL Server – Manual Procedure


This article describes techniques to repair SQL Server – Suspect Mode Issue and ways to recover SQL Server. You can know the basics and in detail description to resolve & fix SQL Server Issues manually. To know more read the article below.

What is SQL Server?


SQL Server is a RDBMS popularly known as relational database management system. It supports the standard SQL language, ANSI SQL. But, this Server mainly supports T-SQL, which is its own implementation. The main interface of this server is SSMS or SQL Server Management Studio. It is popularly abbreviated as MSSQL as well as Microsoft SQL Server.

fix SQL Server

SQL Server Issue:


We often see the database users in trouble, when their SQL Server database is in suspect mode. Under this situation a user is ready to pay for bringing the database in normal state or online. Taking right action at that time saves the database from any data loss, but, not having much information about the suspect state of the database can put the database in more dangerous condition. In this article, first of all we will discuss what is SQL Server suspect mode and what are the reasons for a database suspect mode and how to recover SQL Server which is marked as suspect or corrupted.

Causes for SQL Server Marked as Suspect or Corrupted


What is SQL Server suspect mode ?

Sometimes the SQL Server database becomes inaccessible due to some background issues or due to some hardware level issues on the user machine where the SQL database were located. In such situations the database cannot start until it bring back online from the suspect mode in SQL Server. Then the user checks the error log to find the actual reasons behind the suspect or corrupt database.

What is the cause for a database to go Suspect ?

This Server can go to the suspect mode due to various reasons. Some of the possible reasons are discussed below:

  • A system hardware failure
  • Improper shutdown of SQL database or sudden power failure.
  • SQL database or log file corruption
  • Shortage of Disk Space
  • Missing SQL database log file

These above causes can be the reasons for SQL database marked suspect. To know the actual reason of this problem, one can see the error log for the particular database on SQL Server 2005 and its higher version. This will help in filtering out the database which is in suspect mode and recover SQL Server.

How to Repair SQL Server Database from Suspect Mode?


To repair SQL Server which is marked as suspect or corrupted, you need to execute the below T-SQL code and set the database to Emergency mode.

ALTER DATABASE SET EMERGENCY

The above T-SQL code will help in bringing the database in Emergency mode. After switching the database to Emergency mode, one can execute the DBCC CHECKDB command to check the database for any kind of inconsistency. If you find any inconsistency or get any error message after executing the DBCC CHECKDB command then you need to switch the database to single user mode by executing below command :

ALTER DATABASE SET SINGLE_USER WITH ROLLBACK IMMEDIATE

After executing the above command successfully, you need to take backup of your database before you begin to repair SQL Server (which is very important for the next steps). Now, run the following command to bring the database online:

dbcc checkdb ('',repair_allow_data_loss)

Once the above command will execute successfully, the database which was marked as suspected will bring online.

Note: The repair_allow_data_loss is one of the most dangerous command of this Server. This command is used in a very last resort when there is not any other option, as it is a one-way command or can be the cause of a data loss while you try to recover SQL Server.

Conclusion


In case of database file corruption, there could be probably the hardware level issue. So, it is better to have a good SQL recovery strategy planned to tackle such type of failures or restore SQL Server from a last good backup to save your time. During the procedure to repair SQL Server database, it is important to keep in mind that, do not detach the database which is marked as suspected otherwise you will lose all the chances to recover SQL Server.