Displays or changes the automatic UPDATE STATISTICS setting for a specific index and statistics, or for all indexes and statistics for a given table in the current database.
Note In the context of this stored procedure, the term index refers to statistics on the table.
sp_autostats [@tblname =] 'table_name'
[, [@flagc =] 'stats_flag']
[, [@indname =] 'index_name']
0 (success) or 1 (failure)
If stats_flag is specified, this procedure reports the action that was taken but returns no result set.
If stats_flag is not specified, sp_autostats returns this is the result set.
Column name | Data type | Description |
---|---|---|
Index Name | varchar(60) | Name of the index. |
AUTOSTATS | varchar(3) | Current automatic UPDATE STATISTICS setting: OFF or ON. |
Last Updated | datetime | Date the statistics were last updated. |
Execute permissions default to the table owner.
This example displays the current statistics status of all indexes on the authors table.
USE pubs
EXEC sp_autostats authors
This example enables the automatic statistics setting for all indexes of the authors table.
USE pubs
EXEC sp_autostats authors, 'ON'
This example disables the automatic statistics setting for the au_id index of the authors table.
USE pubs
EXEC sp_autostats authors, 'OFF', au_id
CREATE INDEX | sp_createstats |
CREATE STATISTICS | sp_dboption |
DBCC SHOW_STATISTICS | UPDATE STATISTICS |
DROP STATISTICS | System Stored Procedures |