Skip to content

Latest commit

 

History

History
113 lines (87 loc) · 4.85 KB

File metadata and controls

113 lines (87 loc) · 4.85 KB
title DROP STATISTICS (Transact-SQL) | Microsoft Docs
ms.custom
ms.date 03/22/2016
ms.prod sql
ms.prod_service database-engine, sql-database, sql-data-warehouse, pdw
ms.reviewer
ms.technology t-sql
ms.topic language-reference
f1_keywords
DROP STATISTICS
DROP_STATISTICS_TSQL
dev_langs
TSQL
helpviewer_keywords
removing statistics
column statistics [SQL Server]
DROP STATISTICS statement
deleting statistics
dropping statistics
table statistics [SQL Server]
statistical information [SQL Server], removing
ms.assetid 222806b7-4e45-445b-8cd0-bd5461f3ca4a
author CarlRabeler
ms.author carlrab
monikerRange >=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||=sqlallproducts-allversions||>=sql-server-linux-2017||=azuresqldb-mi-current

DROP STATISTICS (Transact-SQL)

[!INCLUDEtsql-appliesto-ss2008-all-md]

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

Topic link icon Transact-SQL Syntax Conventions

Syntax

-- Syntax for SQL Server and Azure SQL Database  
  
DROP STATISTICS table.statistics_name | view.statistics_name [ ,...n ]  
-- Syntax for Azure SQL Data Warehouse and Parallel Data Warehouse  
  
DROP STATISTICS [ schema_name . ] table_name.statistics_name   
[;]  

Arguments

table | view
Is the name of the target table or indexed view for which statistics should be dropped. Table and view names must comply with the rules for Database Identifiers. Specifying the table or view owner name is optional.

statistics_name
Is the name of the statistics group to drop. Statistics names must comply with the rules for identifiers

Remarks

Be careful when you drop statistics. Doing so may affect the execution plan chosen by the query optimizer.

Statistics on indexes cannot be dropped by using DROP STATISTICS. Statistics remain as long as the index exists.

For more information about displaying statistics, see DBCC SHOW_STATISTICS (Transact-SQL).

Permissions

Requires ALTER permission on the table or view.

Examples

A. Dropping statistics from a table

The following example drops the statistics groups (collections) of two tables. The VendorCredit statistics group (collection) of the Vendor table and the CustomerTotal statistics (collection) of the SalesOrderHeader table are dropped.

-- Create the statistics groups.  
USE AdventureWorks2012;  
GO  
CREATE STATISTICS VendorCredit  
    ON Purchasing.Vendor (Name, CreditRating)  
    WITH SAMPLE 50 PERCENT  
CREATE STATISTICS CustomerTotal  
    ON Sales.SalesOrderHeader (CustomerID, TotalDue)  
    WITH FULLSCAN;  
GO  
DROP STATISTICS Purchasing.Vendor.VendorCredit, Sales.SalesOrderHeader.CustomerTotal;  
  

Examples: [!INCLUDEssSDWfull] and [!INCLUDEssPDW]

B. Dropping statistics from a table

The following examples drop the CustomerStats1 statistics from table Customer.

DROP STATISTICS Customer.CustomerStats1;  
DROP STATISTICS dbo.Customer.CustomerStats1;  
  

See Also

ALTER DATABASE (Transact-SQL)
CREATE INDEX (Transact-SQL)
CREATE STATISTICS (Transact-SQL)
sys.stats (Transact-SQL)
sys.stats_columns (Transact-SQL)
DBCC SHOW_STATISTICS (Transact-SQL)
sp_autostats (Transact-SQL)
sp_createstats (Transact-SQL)
UPDATE STATISTICS (Transact-SQL)
EVENTDATA (Transact-SQL)
USE (Transact-SQL)