How to troubleshoot SQL Server consistency errors

Source: Internet
Author: User
Tags count

If DBCC CHECKDB finds fewer conformance errors, you can use the   DBCC UPDATEUSAGE (DatabaseName, dbo). ObjectName "); Statement corrects the count of rows, used pages, reserved pages, leaf pages, and data pages for each partition in a table or index. However, if there is a large number of consistency errors in the database. For example, the following:

DBCC results for ' jo_t_cutxx '. Message 2508, Level 16, State 1, line 1th the In-row data USED page count for object "JO_T_CUTXX", index ID 2, partition ID 6266925350 91200, alloc unit ID 626692535091200 (type In-row data) is incorrect.
    
Run DBCC updateusage. Message 2508, Level 16, State 3, line 1th the In-row data rsvd page count for object "JO_T_CUTXX", index ID 2, partition ID 6266925350 91200, alloc unit ID 626692535091200 (type In-row data) is incorrect.
    
Run DBCC updateusage. Message 2508, Level 16, State 1, line 1th the In-row data USED page count for object "JO_T_CUTXX", index ID 3, partition ID 9081675118 01856, alloc unit ID 908167511801856 (type In-row data) is incorrect.
    
Run DBCC updateusage. Message 2508, Level 16, State 3, line 1th the In-row data rsvd page count for object "JO_T_CUTXX", index ID 3, partition ID 9081675118 01856, alloc unit ID 908167511801856 (type In-row data) is incorrect.
    
Run DBCC updateusage. Message 2508, Level 16, State 1, line 1th the In-row data USED page count for object "Jo_t_cutxx",Index ID 4, partition ID 1189642488512512, alloc unit ID 1189642488512512 (type In-row data) is incorrect.
    
Run DBCC updateusage. Message 2508, Level 16, State 3, line 1th the In-row data rsvd page count for object "JO_T_CUTXX", index ID 4, partition ID 1189642488 512512, alloc unit ID 1189642488512512 (type In-row data) is incorrect.
    
Run DBCC updateusage. Message 2508, Level 16, State 1, line 1th the In-row data USED page count for object "JO_T_CUTXX", index ID 5, partition ID 1471117465 223168, alloc unit ID 1471117465223168 (type In-row data) is incorrect.
    
Run DBCC updateusage. Message 2508, Level 16, State 3, line 1th the In-row data rsvd page count for object "JO_T_CUTXX", index ID 5, partition ID 1471117465 223168, alloc unit ID 1471117465223168 (type In-row data) is incorrect.
    
Run DBCC updateusage.
    
There are 0 rows in 0 pages for object "Jo_t_cutxx".
    
CHECKDB found 0 allocation errors and 8 consistency errors in table ' Jo_t_cutxx ' (Object ID 972634608). ....................................................................................
    
................................................................... .................
    
....................................................................................

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/database/SQLServer/

It's a bit inefficient and tedious to make corrections to the number of pages and rows in a catalog view. If the database is not large, you want to execute the following statement for all tables, you can use the following statement: (Of course, updating the statistics statement is not necessary, in order to ensure that the system view, table information is correct, it is necessary to collect, update the statistics)

Use master
     
go
     
EXEC sp_msforeachdb@command1= "print"? EXEC [?]. Dbo.sp_updatestats "Use
     
master
     
go
     
EXEC sp_msforeachdb@command1= ' print '? ' DBCC updateusage (?) "

The disadvantage is that a DBCC UPDATEUSAGE is performed on all objects, and if the database is large, the script executes more slowly.

Author: The Hermit of Xiaoxiang

Source: http://www.cnblogs.com/kerrycode/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.