Açıklama


Bu sorun yaşandığı durumlarda SQL'in çalıştığı sunucu diskinde SQL'in yazdığı loglardan dolayı hiç yer kalmayabilir, log'ların tutulduğu dizini (..\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Log) kontrol ederek sorunu tespit ettikten sonra çözüm için izlenebilecek çeşitli yollar mevcut.


Çözüm


Sorunun varlığından emin oldunduktan sonra Emakin servisleri durdurulup DBCC TABLECHECK('table_name') komutu ile sırası ile tüm tablolardaki index'lerin corrupt olup olmadıkları kontrol edilmelidir. Problemli olan indexlerde aşağıdaki gibi bir hata mesajı görünecektir:

Msg 8951, Level 16, State 1, Line 1
Table error: table 'wXmlDatabaseRegistry' (ID 527340943). Data row does not have a matching index row in the index 'ItemId' (ID 2). Possible missing or invalid keys for the index row matching:
Msg 8955, Level 16, State 1, Line 1
Data row (1:1671679:29) identified by (Id = 'BE4488CC-E830-478A-9F2A-753FA2CB805C') with index values 'ItemId = '46B51F18-7741-4ED6-B9EC-FE29687F5501' and Id = 'BE4488CC-E830-478A-9F2A-753FA2CB805C''.
Msg 8951, Level 16, State 1, Line 1
Table error: table 'wXmlDatabaseRegistry' (ID 527340943). Data row does not have a matching index row in the index 'ItemId' (ID 2). Possible missing or invalid keys for the index row matching:
Msg 8955, Level 16, State 1, Line 1
Data row (1:1778083:5) identified by (Id = '7A1E756D-6CB7-43A4-A36A-E947A54F82D5') with index values 'ItemId = '53116AE2-F0A7-4139-8776-7A2C21D18D0A' and Id = '7A1E756D-6CB7-43A4-A36A-E947A54F82D5''.
Msg 8951, Level 16, State 1, Line 1
Table error: table 'wXmlDatabaseRegistry' (ID 527340943). Data row does not have a matching index row in the index 'ItemId' (ID 2). Possible missing or invalid keys for the index row matching:
Msg 8955, Level 16, State 1, Line 1
Data row (1:1642897:31) identified by (Id = '9452954D-BE9A-4383-8D84-2FB73F604D33') with index values 'ItemId = '96B1EE42-E138-4AB2-92DC-0B3D7CC063D4' and Id = '9452954D-BE9A-4383-8D84-2FB73F604D33''.
DBCC results for 'wXmlDatabaseRegistry'.
There are 1204292 rows in 21832 pages for object "wXmlDatabaseRegistry".
CHECKTABLE found 0 allocation errors and 3 consistency errors in table 'wXmlDatabaseRegistry' (object ID 527340943).
repair_rebuild is the minimum repair level for the errors found by DBCC CHECKTABLE (ALTIKARETEST.dbo.wXmlDatabaseRegistry).
DBCC execution completed. If DBCC printed error messages, contact your system administrator.


Corrupt olan indexleri bulma işleminin ardından bu indexlere sağ tıklanarak gelen menüden "Script Index as" -> "CREATE To" seçeneklerine tıklayıp her bir index'i tekrar yaratacak scriptler alınır, sonrasında indexler drop edilir ve bu scriptler ile tekrar oluşturulur.


Bu yönteme alternatif olarak aşağıdaki linkten ulaşabileceğiniz yöntemi de deneyebilirsiniz:

https://logicalread.com/cheat-dbcc-to-fix-sql-server-index-corruption-syntm01/#.WqKQMOjFJPY