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/