How to check database corruption in SQL server

How to Check Database Corruption in SQL Server? – A Quick Guide

If you are facing difficulty in searching how to check database corruption in SQL server, you are at the right place. In the following sections, we discuss a couple of solutions related to fixing a corrupted database i.e. either by manual method or by third-party software. Further, this tool can assist you to repair a corrupted database and recover it without any data loss. 

For instance, you have a healthy database. However, due to an inevitable incident such as a server crash, it becomes inaccessible. Besides this, there can be other incidents like problems with hardware or software, viruses or malware attacks, and many more. On the other hand, if you’re fortunate enough, you might get an error message specifying database corruption in SQL Server. In fact, there can be scenarios where you might fail to identify corruption sometimes because you have no longer access to a database. As a result, it is important to detect corruption in a SQL Server database before time. 

Methods for How to Check SQL Server Database Corruption

SQL Server has the built-in mechanisms to find out a database corruption problem: 

Solution#1 – Check SQL Server Suspect Pages

In the first place, you should examine the system table (i.e., suspect_ pages) instead of checking the entire database for corruption. Adding to the same, you can find the system table under the .msdb SQL server database. The following is one of the simple fixes on how to check database corruption in SQL Server.

By checking the suspect_pages table, you can quickly grab the corrupted pages in your database. Thus, to perform the operation, run the below query to find the damaged pages in the ‘suspect_pages’ table.

SELECT * FROM  sdb..suspect_pages

Solution#2 – Utilize the PAGE Verify Option to Check SQL Database Corruption

CHECKSUM is a handy ‘PAGE_VERIFY’ feature to detect page-level corruption i.e. due to I/O errors. 

Specifically, databases of SQL Server 2008 and above versions use the ‘CHECKSUM’ feature as a default page verification setting. However, this is not the case with SQL Server 2005 instances. While inspecting databases migrated from a previous server instance, you could find the PAGE_VERIFY option i.e. configure as TORN PAGE DETECTION or NONE. In like manner, this is one of the solutions on how to check database corruption in SQL Server. 

In addition, you have the flexibility to modify the database option to CHECKSUM using the SQL Server Management Studio (SSMS) or T-SQL. After that, change the PAGE_VERIFY option to CHECKSUM using SSMS. 

  • Firstly, right-click on the database you require to check for corruption. Then, click on the database properties. 
  • Under the ‘Database Properties’ Tab, Click on Options. Now, on the ‘Options’ page, scroll down to the Recovery label. Next, click on the drop-down corresponding to Page Verify, then choose CHECKSUM. At last, tap on OK
Set Page Verify DB Option to Checksum

Altering the PAGE_VERIFY Option to CHECKSUM through the T-SQL 

Use the following T-SQL command to set the ‘PAGE VERIFY CHECKSUM’ option: 

ALTER DATABASE SET PAGE_VERIFY CHECKSUM WITH NO_WAIT;

Solution#3 – Run DBCC CHECKDB on How to Check Database Corruption in SQL Server

Regularly running DBCC CHECKDB is essential to check for database integrity and detecting corruption in the SQL Server database. 

In the event of finding corruption, this command will return consistent errors. And also, provides an extensive error message explaining the causes of SQL Server database corruption. 

DBCC CHECKDB ‘database_name’;

Alternative Solution#4: A Tested Matrix to View Corrupted MDF Files

By using this professional MDF file opener, you can easily read, view, and open .mdf files. Further, it is a trusted and suggested source by specific MVPs and administrators around the globe. Even if your file is corrupted or damaged, you can view the SQL Server database without any data loss. Moreover, it also allows you to open essential objects such as tables, deleted records, stored procedures, indexes, triggers, etc. In addition, the tool is compatible to run on Windows, Mac, and other OS. Meanwhile, in seconds, this tool can be effortlessly downloaded and installed. 

Alternative Solution#5: A Smart Wizard to Repair Corrupted MDF and NDF Files

Most of the time, corruption of SQL Server database files can lead to data loss and system instability. On one hand, the conventional methods of recovering the MDF and NDF files require technical expertise. Adding to it, it may not offer a successful recovery of files. On the other hand, to address such a challenge, you can rely on an innovative solution i.e. a SysTools SQL Recovery Tool. Also, this tool uses the latest algorithms to simplify the repair process and lead on how to check database corruption in SQL Server. 

Moreover, this professional SQL database repair tool offers an excellent approach to address issues within a corrupted SQL database. To sum up, this powerful tool excels in rectifying damaged MDF and NDF files.

Also Read: SQL CERTIFICATION FREE: EXPECTATION VS. REALITY – An Extensive Comparision 

The Final Say

An SQL Server database corruption can occur due to several factors like system crash, I/O subsystem failure, virus or malware intrusion, and many more. In particular, detecting a corrupted database can be nerve-wracking, as it may remain undetected until it becomes inaccessible. Fortunately, this blog discusses methods for identifying and addressing database corruption. I hope from the above information, your query on how to check database corruption in SQL Server. Thank you for giving your valuable time for reading!