DROP STATISTICS

Transact-SQL Reference

Transact-SQL Reference

DROP STATISTICS

Drops statistics for multiple collections within the specified tables (in the current database).

Syntax

DROP STATISTICS table.statistics_name | view.statistics_name [ ,...n ]

Arguments

table | view

Is the name of the target table or indexed view for which statistics should be dropped. Table and view names must conform to the rules for identifiers. For more information, see Using Identifiers. Specifying the table or view owner name is optional.

statistics_name

Is the name of the statistics group to drop. Statistics names must conform to the rules for identifiers.

n

Is a placeholder indicating that more than one statistics_name group (collection) can be specified.

Remarks

Be careful when dropping statistics because dropping statistics may affect the plan chosen by the query optimizer.

For more information about displaying statistics, see "DBCC SHOW_STATISTICS" in this volume. For more information about updating statistics, see "UPDATE STATISTICS" and the auto update statistics option of "sp_dboption" in this volume. For more information about creating statistics, see "CREATE STATISTICS", "CREATE INDEX", and the auto create statistics option of "sp_dboption" in this volume.

Permissions

DROP STATISTICS permissions default to the table or view owner, and are not transferable. However, members of the db_owner and db_ddladmin fixed database roles and sysadmin fixed server role can drop any object by specifying the owner in DROP STATISTICS.

Examples

This example drops the anames statistics group (collection) of the authors table and the tnames statistics (collection) of the titles table.

-- Create the statistics groups.
CREATE STATISTICS anames 
   ON authors (au_lname, au_fname)
   WITH SAMPLE 50 PERCENT
GO
CREATE STATISTICS tnames
   ON titles (title_id)
   WITH FULLSCAN
GO
DROP STATISTICS authors.anames, titles.tnames
GO

See Also

CREATE INDEX

CREATE STATISTICS

DBCC SHOW_STATISTICS

sp_autostats

sp_createstats

sp_dboption

UPDATE STATISTICS

USE