Click to Rate and Give Feedback
MSDN
MSDN Library
SQL Server
SQL Server 2008
Database Engine
Technical Reference
 sp_updatestats (Transact-SQL)

  Switch on low bandwidth view
Community Content
In this section
Statistics Annotations (0)
Other versions are also available for the following:
SQL Server 2008 Books Online (June 2009)
sp_updatestats (Transact-SQL)

Updated: 26 February 2009

Runs UPDATE STATISTICS against all user-defined and internal tables in the current database.

For more information about UPDATE STATISTICS, see UPDATE STATISTICS (Transact-SQL). For more information about statistics, see Using Statistics to Improve Query Performance.

Topic link icon Transact-SQL Syntax Conventions

sp_updatestats [ [ @resample = ] 'resample']
[ @resample =] 'resample'

Specifies that sp_updatestats will use the RESAMPLE option of the UPDATE STATISTICS statement. If 'resample' is not specified, sp_updatestats updates statistics by using the default sampling. resample is varchar(8) with a default value of NO.

0 (success) or 1 (failure)

sp_updatestats executes UPDATE STATISTICS, by specifying the ALL keyword, on all user-defined and internal tables in the database. sp_updatestats displays messages that indicate its progress. When the update is completed, it reports that statistics have been updated for all tables.

sp_updatestats updates statistics on disabled nonclustered indexes and does not update statistics on disabled clustered indexes.

sp_updatestats updates only the statistics that require updating based on the rowmodctr information in the sys.sysindexes catalog view, thus avoiding unnecessary updates of statistics on unchanged rows.

For databases with a compatibility level below 90, executing sp_updatestats does not preserve the latest NORECOMPUTE setting for specific statistics. For databases with a compatibility level of 90 or higher, sp_updatestats does preserves the latest NORECOMPUTE option for specific statistics. For more information about disabling and re-enabling statistics updates, see Using Statistics to Improve Query Performance.

Requires membership in the sysadmin fixed server role, or ownership of the database (dbo).

The following example updates the statistics for tables in the AdventureWorks database.

USE AdventureWorks;
GO
EXEC sp_updatestats 

Updated content

Revisions throughout the document to improve accuracy.

Added reference to new statistics content in the topic Using Statistics to Improve Query Performance.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker