Databases Reference
In-Depth Information
For example, run the following statement to verify that there are no statistics on the
UnitPrice column of the Sales.SalesOrderDetail table:
DBCC SHOW_STATISTICS ( 'Sales.SalesOrderDetail' , UnitPrice )
Listing 3-3.
If no statistics exists, which is the case for a fresh installation of the AdventureWorks
database, you will receive the following error message:
Msg 2767, Level 16, State 1, Line 2
Could not locate statistics 'UnitPrice' in the system catalogs.
By then running the following query, the Query Optimizer will automatically create
statistics on the UnitPrice column, which is used in the query predicate.
SELECT * FROM Sales . SalesOrderDetail
WHERE UnitPrice = 35
Listing 3-4.
Running the previous DBCC SHOW_STATISTICS statement again will now show a
statistics object similar to the following output (displayed as text and edited to fit
the page).
Search WWH ::




Custom Search