Corruption in SQL databases may result due to an instant power failure during a transaction or due to a hardware malfunction in the computer on which server installed. Predominantly, hardware malfunction is the major reason of corruption in databases. Other causes that can incur corruption in the SQL server databases are database duplication, creating triggers on system tables, renaming the primary file group, etc. This corruption may remain obscure till the time you do not interact with the corrupt data. If corruption affects the backup files, you can never restore the database to its previous consistent state.
Few error messages encountered frequently in the event of SQL Server database corruption are listed below:
- Table error: Object ID 0, index ID 0, and page ID (1:105). The PageId in the page header = (0:0)
- Internal error. buffer provided to read column value is too small
- Conflict occurred in database'db_name', table 'table_name', column 'column_name'
- Memory or buffer error, space provided to read column is too small
To get away with these corruption problems, you should always have a good backup strategy in the first place. Using the most recent backup, you can perform MDF recovery and retrieve all your invaluable data stored in the database. However, it is usually experienced that maintaining the most updated backup is not always possible.
In such circumstances, you should use the DBCC CHECKDB command-line tool to repair data corruption. To check physical consistency of the database, run the following command:
'DBCC CHECKDB('neo') WITH PHYSICAL_ONLY; GO'
The two major repair options used with DBCC CHECKDB are:
- REPAIR_ALLOW_DATA_LOSS
- This option will usually try to repair all reported errors and might also cause some data loss. Therefore, you should use this option only as the last resort
- REPAIR_REBUILD:
- This option does not incur data loss. For example, if a non-clustered index is damaged, you can be easily repaired by rebuilding the index.
Supported Versions of MS SQL Server: 2008 R2, 2008, 2008*64, 2008 Express, 2005, 2005*64, Express, 2000, 2000*64, 7.0,