Export (0) Print
Expand All
Expand Minimize

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;
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft