File Repair
Database Recovery with Piecemeal Restore in Microsoft SQL Server
July 28, 2026| 7 min read
Summary: This guide talks about SQL database integrity checks. It discusses how often you should run database integrity checks, methods to check SQL database integrity, and what you can do if the integrity checks fail or report errors. It explains using the DBCC CHECKDB command to fix consistency errors reported by database integrity check. You may also use Stellar Repair for MS SQL software to fix database consistency errors in a critical database without the risk of data loss.
Free Download 100% SecurePerforming integrity checks is part of the SQL Server database maintenance plan that helps ensure consistency of the database.
To be more precise, running integrity checks help maintain the effectiveness of production database or restored backup by detecting consistency errors (corruption) in the database.
Performing integrity checks can be a time-consuming and resource-intensive process. Thus, it is important to understand how often you should run integrity checks. To decide this, let’s take two examples:
Following are the two methods to check SQL database integrity:
If running the query report “0 allocation errors and 0 consistency errors”, it means that the database is healthy. If it reports consistency errors, check the recommended minimum level of repair you will need to perform at the bottom of message summary (refer to the image below):
Figure 1 - Executing DBCC CHECKDB to Run Database Integrity Check
Follow these steps to check db integrity using ‘Check Database Integrity Task’ in SQL Server Integration Services (SSIS):
Note: Check the ‘Include indexes’ checkbox if you want to perform integrity checks on the database index pages as well.
The tasks will be displayed with green status if everything is OK.
But, sometimes, the integrity checks may fail and show errors. This will happen when the SQL database is corrupted.
If SQL database integrity check fails on a database, it is advisable to restore the SQL database from the latest backup. If you don’t have backups, you can perform the database repair process by running DBCC CHECKDB command with ‘REPAIR_ALLOW_DATA_LOSS’ option.
Read this: How to Repair SQL Database using DBCC CHECKDB Command?
The ‘REPAIR_ALLOW_DATA_LOSS’ option can fix database consistency errors. However, it only helps fix the physical structure of the database, not the internal data integrity. In other words, running the DBCC CHECKDB command with ‘REPAIR_ALLOW_DATA_LOSS’ option can result in data loss.
You can also fix SQL database consistency errors, by running the ‘REPAIR_REBUILD’ command. The command is usually used for correcting issue in non-clustered indexes. This option doesn’t result in data loss.
If executing the DBCC CHECKDB command failed to preserve data integrity and consistency of your SQL Server database, you can use an alternative SQL Database Repair Tool, such as Stellar Repair for MS SQL to resolve the issue.
The software repairs severely corrupted SQL database MDF/NDF files while preserving data integrity. It can fix corruption in SQL databases on both Windows and Linux systems. The SQL repair tool can recover all database objects, including deleted table records of SQL version 2019, 2017, 2016, and earlier versions.
When running SQL Server check database integrity periodically to ensure that the database is healthy and is not corrupted. This article explains the steps you need to perform in SSIS to perform integrity checks on a SQL Server database. It also discusses using the DBCC CHECKDB command with repair options when your integrity check fails. But, executing DBCC CHECKDB with ‘REPAIR_ALLOW_DATA_LOSS’ command can result in data loss and cause inconsistency errors. In that case, a better alternative is to use Stellar Repair for MS SQL to fix the database consistency errors without the risk of data loss.