Creates single-column statistics for all eligible columns for all user tables in the current database. The new statistic has the same name as the column on which it is created. Computed columns and columns of the ntext, text, or image data types cannot be specified as statistics columns. Columns already having statistics are not touched (for example, the first column of an index or a column with explicitly created statistics). A CREATE STATISTICS statement is executed for each column that satisfies the above restrictions. FULLSCAN is executed if fullscan is specified.
sp_createstats [[@indexonly =] 'indexonly']
[,[@fullscan =] 'fullscan']
[,[@norecompute =] 'norecompute']
0 (success) or 1 (failure)
None
Permissions default to members of the sysadmin fixed server role and the db_owner fixed database role.
This example creates statistics for all eligible columns for all user tables in the current database.
EXEC sp_createstats
This example creates statistics for only the columns participating in an index.
EXEC sp_createstats 'indexonly'
CREATE STATISTICS | UPDATE STATISTICS |
DBCC SHOW_STATISTICS | System Stored Procedures |
DROP STATISTICS |