How do I find all the statistics and statistics columns on a specified object?

Published 09 August 07 02:59 AM | SQL Master 

Run this TSQL on the database where you want to obtain the statistics information:

SELECT s.name AS statistics_name
    ,c.name AS column_name
    ,sc.stats_column_id
FROM sys.stats AS s
INNER JOIN sys.stats_columns AS sc
    ON s.object_id = sc.object_id AND s.stats_id = sc.stats_id
INNER JOIN sys.columns AS c
    ON sc.object_id = c.object_id AND c.column_id = sc.column_id
WHERE s.object_id = OBJECT_ID('<schema_name.object_name>');

Comments

# Other SQL Server Blogs around the Web said on August 9, 2007 3:15 AM:

Run this TSQL on the database where you want to obtain the statistics information: SELECT s.name AS statistics_name

Anonymous comments are disabled

About SQL Master

**__________________________________** SQL Server MVP, Sr. DBA & industry expert. - Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it. It is also a power and you will gain by sharing it.