How to Update Your SQL Database Statistics

In this article we will see how to update you SQL Database Statistics.


The query optimizer uses statistics to create query plans that improve query performance. For most queries, the query optimizer already generates the necessary statistics for a high quality query plan; in a few cases, you need to create additional statistics or modify the query design for best results. This topic discusses statistics concepts and provides guidelines for using query optimization statistics effectively.

Read more details here : SQL Server Statistics

Command to update you SQL Database Statistics :


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

Syntax : sp_updatestats [ [ @resample = ] ‘resample’]

Arguments : 

[ @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.

Return Code Value : 0 (success) or 1 (failure)

Example :

USE DatabaseName;
EXEC sp_updatestats; 

Read more about sp_updatestats :

Understanding What sp_updatestats Really Updates


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s