Printer Friendly Version      Send     
Click to Rate and Give Feedback
MSDN
MSDN Library
SQL Server
SQL Server 2008
 CREATE STATISTICS (SQL Server Compa...
Other versions are also available for the following:
SQL Server Compact 3.5 Service Pack 1 Books Online
CREATE STATISTICS (SQL Server Compact)

Creates a histogram (a bar chart) of the supplied table and index or indices.

CREATE STATISTICS ON < table_name > [ . <index_name> ]
    WITH FULLSCAN {, NORECOMPUTE }
table_name

Specifies the name of the table to create the statistics on.

index_name

The index to create the statistics on. If no index is specified, the statistics are created for all indexes in the table.

FULLSCAN

Specifies that all rows in the table or view should be read to gather the statistics.

NORECOMPUTE

Specifies that automatic recomputation of the statistics should be disabled. If this option is specified, the Database Engine continues to use old statistics even as the data changes. The statistics are not automatically updated and maintained by the Database Engine, which can produce suboptimal plans.

Important   We recommend that this option be used rarely, and only by a trained system administrator.

The following example creates a histogram of the MyCustomers table and index.

CREATE TABLE MyCustomers (CustID int, CompanyName nvarchar(50));
CREATE UNIQUE INDEX idxCustId ON MyCustomers (CustId);
DROP STATISTICS ON MyCustomers.idxCustId;
CREATE STATISTICS ON MyCustomers.idxCustId WITH FULLSCAN, NORECOMPUTE;
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker