How to create statistics (Query Analyzer)

How to Install SQL Server 2000

How To

How to create statistics (Query Analyzer)

To create statistics

  1. On the Query menu, click Show Execution Plan.

  2. Execute the Transact-SQL script in the query pane.

  3. In the result pane, click the Execution Plan tab.

  4. Right-click the icon of the physical operator that suggests that statistics need to be created (table name in red), and then click Create Missing Statistics. The database, table, and column(s) that the Graphical Execution Plan suggests need new statistics are automatically selected.

  5. Optionally, in Statistics name, enter the name for the statistics.

  6. Optionally, in Amount of data to sample, select:
    • Default to let Microsoft® SQL Server™ determine the number of rows to sample automatically.

    • Sample all the data to instruct SQL Server to sample all of the data in the table.

    • Sample % of the data and enter a percentage of data to sample to base the statistics on.
  7. Optionally, select Do not automatically recompute statistics (not recommended) to prevent SQL Server from updating statistics automatically as the data is updated.

  8. Optionally, click Edit SQL to view and edit the Transact-SQL statement used to create or update the statistics.

See Also

Graphically Displaying the Execution Plan Using SQL Query Analyzer

Statistical Information