sp_updatestats
Runs UPDATE STATISTICS against all user-defined tables in the current database.
Syntax
sp_updatestats [[@resample =] 'resample']
Return Code Values
0 (success) or 1 (failure)
Arguments
[@resample=] 'resample'
Specifies that sp_updatestats will use the RESAMPLE option of the UPDATE STATISTICS command. New statistics will inherit the sampling ratio from the old statistics. If 'resample' is not specified, sp_updatestats updates statistics using the default sampling. This parameter is varchar(8) with a default value of 'NO'.
Remarks
sp_updatestats displays messages indicating its progress. When the update is completed, it reports that statistics have been updated for all tables.
Permissions
Only the DBO and members of the sysadmin fixed server role can execute this procedure.
Examples
This example updates the statistics for tables in the pubs database.
USE pubs
EXEC sp_updatestats