Adding statistics for a column with update statistics

To add statistics for the price column in the titles table, enter:

update statistics titles (price) 

To specify the number of histogram steps for a column, use:

update statistics titles (price) 
   using 50 values

This command adds a histogram for the titles.pub_id column and generates density values for the prefix subsets pub_id; pub_idpubdate; and pub_id, pubdate, title_id:

update statistics titles(pub_id, pubdate, title_id)

However, this command does not create a histogram on pubdate and title_id, since a separate update statistics command is needed for every column for which a histogram is desired.

NoteRunning update statistics with a table name updates histograms and densities for leading columns for indexes only; it does not update the statistics for unindexed columns. To maintain these statistics, run update statistics and specify the column name, or run update all statistics.