Friday, May 27, 2011

Analyzing DBCC CHECKDB failure in severe corruption cases and MDF Database Recovery

The DBCC CHECKDB utility is used more often than not by almost all SQL database users. This eminent utility makes use of an internal database snapshot to obtain transactional consistency of the database. It uses this information to check and repair SQL database following a three stage process. In the first stage, it performs an allocation check. Then it checks all the critical system tables for consistency errors in the second stage. In the final stage, a consistency check of the whole database is performed. Sometimes due to severe corruption, the process cannot be completed. If the CHECKDB utility fails to repair corruption, you should go for SQL recovery through a reliable third-party software.

For instance, you use MS SQL Server 2000. While running CHECKDB on one of your important database files, you notice that the process terminates unexpectedly giving you the following error message:

Database 'DBNAME' consistency errors in sysobjects, sysindexes, syscolumns, or systypes prevent further CHECKNAME processing.”

Cause:
The CHECKDB utility encountered some errors in the second stage that it cannot repair. So, it simply aborts the process before reaching the third stage and throws the above specified error message. The completion of the second stage is necessary for executing the third stage.

This could have happened due to metadata corruption in the database system tables. Corruption may make all the components in your database inaccessible. You may use a backup to restore all the lost or inaccessible data. If the backup is missing, you should follow the below mentioned resolution steps to perform MDF file recovery.

Resolution:

Try the following methods to resolve the problem-

Check the SQL Server error log and the Windows application and system log to determine the cause of the problem. If hardware failure caused the problem, run the hardware diagnostics tool.
Run DBCC CHECKDB with proper repair clause to fix corruption.

If the problem still persists, you should take help of a SQL database recovery software. These software are capable of recovering the damaged SQL database components in their original form restoring all their properties and relationships with other components. They retrieve tables, views, queries, indexes, stored procedures, keys, constraints etc. from the corrupt database.