Applies To: SQL Server 2014, SQL Server 2016 Preview
Returns statistics information about columns and indexes on the specified table.
This feature will be removed in the next version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. To obtain information about statistics, query the sys.stats and sys.stats_columns catalog views.
Applies to: SQL Server (SQL Server 2008 through current version), Azure SQL Database
- [ @objname =] 'object_name'
Specifies the table on which to provide statistics information. object_name is nvarchar(520) and cannot be null. A one- or two-part name can be specified.
- [ @results =] 'value'
Specifies the extent of information to provide. Valid entries are ALL and STATS. ALL lists statistics for all indexes and also columns that have statistics created on them; STATS only lists statistics not associated with an index. value is nvarchar(5) with a default of STATS.
0 (success) or 1 (failure)
The following table describes the columns in the result set.
The name of the statistics. Returns sysname and cannot be null.
The keys on which statistics are based. Returns nvarchar(2078) and cannot be null.
Requires membership in the public role.
The following example creates single-column statistics for all eligible columns for all user tables in the AdventureWorks2012 database by executing sp_createstats. Then, sp_helpstats is run to find the resultant statistics created on the Customer table.
USE AdventureWorks2012; GO EXEC sp_createstats; GO EXEC sp_helpstats @objname = 'Sales.Customer', @results = 'ALL';
Here is the result set.