Database Research & Development

  • Home
  • NoSQL
    • NoSQL
    • Cassandra
  • Databases
    • Database Theory
    • Database Designing
    • SQL Server Coding Standards
    • SQL Server
    • PostgreSQL
    • MySQL
    • Greenplum
    • Linux
  • Interviews
    • SQL Server Interviews
    • MySQL Interviews
    • SQL Puzzles
  • DBA Scripts
    • SQL Server DBA Scripts
    • PostgreSQL DBA Scripts
    • MySQL DBA Scripts
    • Greenplum DBA Scripts
  • Home
  • Blog Archives !
  • (: Laugh@dbrnd :)
  • Contact Me !
sqlserverinterviews
Home 2017 March SQL Server: How to repair corrupted Clustered Index using REPAIR_REBUILD option

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

This article is half-done without your Comment! *** Please share your thoughts via Comment ***

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,

1
2
DBCC CHECKDB ('Database_Name', REPAIR_REBUILD)
DBCC CHECKTABLE ('Table_Name', REPAIR_REBUILD)

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

Mar 11, 2017Anvesh Patel
SQL Server: fix error 3183 RESTORE detected an error on page (0:0) in database as read from the backup setSQL Server: Fix - Error 5042 The file ‘FileName’ cannot be removed because it is not empty
Comments: 3
  1. Misha Chawla
    March 22, 2017 at 10:30 am

    Anvesh,

    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.

  2. johnson
    June 16, 2017 at 10:42 am

    Thanks Anvesh for your great help. I tried the manual Solution and fixed index corruption issue in my database , it works far better than any third party tool like Stellar SQL recovery

    • Anvesh Patel
      Anvesh Patel
      June 16, 2017 at 5:25 pm

      Thanks to you Johnson… 🙂

Anvesh Patel
Anvesh Patel

Database Engineer

March 11, 2017 SQL ServerAnvesh Patel, clustered index, database, database research and development, DBCC CHECKDB, DBCC CHECKTABLE, dbrnd, Index corruption, Rebuild Clustered Index, Repair Index, REPAIR_REBUILD, SQL Query, SQL Server, SQL Server Administrator, SQL Server Error, SQL Server Monitoring, SQL Server Performance Tuning, SQL Server Programming, SQL Server Tips and Tricks, TSQL
About Me!

I'm Anvesh Patel, a Database Engineer certified by Oracle and IBM. I'm working as a Database Architect, Database Optimizer, Database Administrator, Database Developer. Providing the best articles and solutions for different problems in the best manner through my blogs is my passion. I have more than six years of experience with various RDBMS products like MSSQL Server, PostgreSQL, MySQL, Greenplum and currently learning and doing research on BIGData and NoSQL technology. -- Hyderabad, India.

About DBRND !

dbrnd

This is a personal blog (www.dbrnd.com).

Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity, unless explicitly stated.

Feel free to challenge me, disagree with me, or tell me I’m completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or anonymous comments) - so keep it polite.

The content of this website is protected by copyright. No portion of this website may be copied or replicated in any form without the written consent of the website owner.

Recent Comments !
  • Anvesh Patel { Sure will do... } – May 27, 12:43 PM
  • Anvesh Patel { Great... } – May 27, 12:41 PM
  • Anvesh Patel { Great... } – May 27, 12:39 PM
  • Anvesh Patel { Great... } – May 27, 12:36 PM
  • Anvesh Patel { Great... } – May 27, 12:28 PM
  • Anvesh Patel { Great... } – May 27, 12:27 PM
  • Anvesh Patel { Great... } – May 27, 12:16 PM
  • Older »
Follow Me !
  • facebook
  • linkedin
  • twitter
  • youtube
  • google
  • flickr
© 2015 – 2019 All rights reserved. Database Research & Development (dbrnd.com)
Posting....