[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

rebuild does not fix NC index error

Posted on 2013-01-22
5
Medium Priority
?
484 Views
Last Modified: 2013-01-23
my understanding is NC index can be easily fixed in data corruption.. but what may block easy rebuild of such a case?
0
Comment
Question by:25112
  • 4
5 Comments
 
LVL 5

Author Comment

by:25112
ID: 38806047
Table error: table 'OptionsReview' (ID 329820287). Data row does not have a matching index row in the index 'NdxOptionsReviewA' (ID 3). Possible missing or invalid keys for the index row matching:
Msg 8955, Level 16, State 1, Line 2
Data row (1:98012:58) identified by (HEAP RID = (1:98012:58)) with index values 'OptionsReviewID = 4146 and HEAP RID = (1:98012:58)'.

NdxOptionsReviewA is a non-clustered non-unique index on OptionsReviewID.

I rebuilt the index NdxOptionsReviewA, but I still get the same error when I run dbcc checkdb or checktable.
0
 
LVL 5

Author Comment

by:25112
ID: 38806095
The funny thing is if I run DBCC CHECKTABLE (OptionsReview) then I get the below:

DBCC results for 'OptionsReview'.
There are 217112 rows in 2332 pages for object "OptionsReview".
DBCC execution completed. If DBCC printed error messages, contact your system administrator.

but
DBCC CHECKDB (POPT) WITH NO_INFOMSGS, ALL_ERRORMSGS
brings back the same errors for this table.
0
 
LVL 5

Author Comment

by:25112
ID: 38806154
i dropped the index and then there is no errors with
DBCC CHECKDB (POPT) WITH NO_INFOMSGS, ALL_ERRORMSGS for that table..

but i recreate that index, then i get the error back.

does that mean the problem is data and not index even though the error message seems to indicate so? what would you recommend for this?
0
 
LVL 70

Accepted Solution

by:
Scott Pletcher earned 2000 total points
ID: 38807926
Heaps can become so "scattered" over time that it can cause issues.

If the table is not too large / can afford the down time (or you have Enterprise+ edition and can do the index changes ONLINE), I'd suggest you try this:

1) Review sys.dm_db_index_usage_stats for that table and see if any NC index could make a good Clus index.
2) Script out all existing NC indexes.
3) Drop all NC indexes.
4) Create a clustered index.
5) OPTIONAL: Drop the clustered index.
6) Recreate all NC indexes, unless that key(s) became the clustered index.
0
 
LVL 5

Author Comment

by:25112
ID: 38810643
100% Right on..thanks Scott..

create CI once did it.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question