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’]
- [ @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)
USE DatabaseName; GO EXEC sp_updatestats;
Read more about sp_updatestats :