SQL Server: How to repair corrupted Clustered Index using REPAIR_REBUILD option

I executed DBCC CHECKTABLE on one of my tables, and I got below error.
“table ‘tbl_students’ (ID 6589332541). Data row does not have a matching index row in the index ‘idx_tbl_students_id’ (ID 88). Possible missing or invalid keys for the index row matching.”

The above error is indicating the corruption of index “idx_tbl_students_id” so few records are missing.
If your index corrupted, there are two possible solutions. One is Restore your database backup and Second is Rebuild your corrupted indexes.

People are using REBUILD command for rebuilding the indexes, but in this article, I repaired the index using option REPAIR_REBUILD of DBCC.

You can use the REPAIR_REBUILD option with DBCC CHECKDB and DBCC CHECKTABLE. While executing those DBCC commands, you can repair corrupted indexes.

This can include quick repairs, such as repairing missing rows in non-clustered indexes, and more time-consuming repairs, such as rebuilding an index.

Following are example,

You can use below article and find script to rebuild all indexes of SQL Server Database:

SQL Server: T-SQL Script to Rebuild all Indexes of a Database

Anvesh Patel
Sort by:   newest | oldest | most voted
Misha Chawla


Thanks for sharing this blog. I agree with you but, In my case, the Repair-Rebuild option did not work. In that case, a third party software “Stellar Phoenix SQL database Repair” helped me to repair corrupt database.