DBCC UPDATEUSAGE (Transact-SQL)
Applies To: SQL Server 2014, SQL Server 2016 Preview
Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).
Reports and corrects pages and row count inaccuracies in the catalog views. These inaccuracies may cause incorrect space usage reports returned by the sp_spaceused system stored procedure.
Applies to: SQL Server (SQL Server 2008 through current version).
DBCC UPDATEUSAGE corrects the rows, used pages, reserved pages, leaf pages and data page counts for each partition in a table or index. If there are no inaccuracies in the system tables, DBCC UPDATEUSAGE returns no data. If inaccuracies are found and corrected and WITH NO_INFOMSGS is not used, DBCC UPDATEUSAGE returns the rows and columns being updated in the system tables.
DBCC CHECKDB has been enhanced to detect when page or row counts become negative. When detected, the DBCC CHECKDB output contains a warning and a recommendation to run DBCC UPDATEUSAGE to address the issue.
Do not run DBCC UPDATEUSAGE routinely. Because DBCC UPDATEUSAGE can take some time to run on large tables or databases, it should not be used only unless you suspect incorrect values are being returned by sp_spaceused.
Consider running DBCC UPDATEUSAGE routinely (for example, weekly) only if the database undergoes frequent Data Definition Language (DDL) modifications, such as CREATE, ALTER, or DROP statements.
A. Updating page or row counts or both for all objects in the current database
The following example specifies 0 for the database name and DBCC UPDATEUSAGE reports updated page or row count information for the current database.
DBCC UPDATEUSAGE (0); GO
B. Updating page or row counts or both for AdventureWorks, and suppressing informational messages
The following example specifies AdventureWorks2012 as the database name and suppresses all informational messages.
DBCC UPDATEUSAGE (AdventureWorks2012) WITH NO_INFOMSGS; GO
C. Updating page or row counts or both for the Employee table
The following example reports updated page or row count information for the Employee table in the AdventureWorks2012 database.
DBCC UPDATEUSAGE (AdventureWorks2012,'HumanResources.Employee'); GO
D. Updating page or row counts or both for a specific index in a table
The following example specifies IX_Employee_ManagerID as the index name.
DBCC UPDATEUSAGE (AdventureWorks2012, 'HumanResources.Employee', IX_Employee_OrganizationLevel_OrganizationNode); GO