Fix Row Page and Counts after a Database Upgrade - SQL Server

If your databases were originally created in SQL 2000 and you plan to upgrade to SQL Server 2005/SQL Server 2008, then you should run DBCC UPDATEUSAGE

The DBCC UPDATEUSAGE reports and corrects inaccurate row and page count for tables and indexes and as a result, when you run the sp_spaceused system stored procedure, the space usage reported may be incorrect. Make sure you run DBCC CHECKDB to see if there are any problems reports (Reference)

It is advisable to run the DBCC UPDATEUSAGE command when the load on the server is not too much, although I believe the impact of running it on a ‘normal’ day traffic should not be much. As given in the BOL, here are some best practices to follow:

  • Always run DBCC UPDATEUSAGE after upgrading a database from SQL Server 2000. The page and row counts are corrected and are maintained thereafter.
  • Do not run DBCC UPDATEUSAGE routinely for databases created in SQL Server 2005 or higher or on upgraded databases that have been corrected once by using DBCC UPDATEUSAGE. 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.


About The Author

Suprotim Agarwal, MCSD, MCAD, MCDBA, MCSE, is the founder of DotNetCurry, DNC Magazine for Developers, SQLServerCurry and DevCurry. He has also authored a couple of books 51 Recipes using jQuery with ASP.NET Controls and a new one recently at The Absolutely Awesome jQuery CookBook.

Suprotim has received the prestigous Microsoft MVP award for nine times in a row now. In a professional capacity, he is the CEO of A2Z Knowledge Visuals Pvt Ltd, a digital group that represents premium web sites and digital publications comprising of Professional web, windows, mobile and cloud developers, technical managers, and architects.

Get in touch with him on Twitter @suprotimagarwal, LinkedIn or befriend him on Facebook

No comments: