What is database suspect mode ?

A database is always in a specific status such as online, offline, recovering, restoring, emergency, suspect, etc. 
Among them today we are going to discuss about suspect mode.
If a database go into suspect mode we cannot work on it or at least can’t connect to the database until it becomes online mode. The main reason for a suspect status is damaging the primary filegroup of the database. So to recover this issue we have to perform some specific actions.

What are the reasons to marks database as Suspect?

Hardware failure.
Database server is not shutdown properly.
Corruption of the database files.
Missing database logging files
Low disk spaces.
SQL cannot complete a rollback or roll forward operations.

Steps to recover the Suspect mode of database

Open SQL Server Management Studio.

Select New Query and we have to turn on emergency mode.by turn on the emergency mode it allows read only access to the administrator. We can do it by,
          ALTER DATABASE  dbName  SET  EMERGENCY

By changing the status then administrator can access it.then by DBCC CHECKDB we can check all logical and physical integrity of the specified database.
          DBCC CHECKDB('dbName')

If we any error by this execution we turn the database into single user mode and make changes.if there are no errors we no need to do the following execution.
          ALTER DATABASE dbName SET SINGLE_USER WITH ROLLBACK IMMEDIATE

Then we can rerun the CHECKDB command as(note that executing the following command is really dangerous as it is one-way command.)
          DBCC CHECKDB [‘dbName’, REPAIR_ALLOW_DATA_LOSS]

At last again we can bring the database from single user mode to multi user mode.
          ALTER DATABASE dbName SET MULTI_USER

By following steps you can fix the suspect mode of the database. Refresh the database server and verify the connectivity. Then you can connect properly.

Running DBCC CHECKDB command regularly we can check the physical and logical integrity of the database.

x

Comments

Popular posts from this blog

What is Rapid Application Development

OOP Concepts