Query to get table statistics details

-> Below query can be used to get the details of statistics on a table.

select distinct object_name(a.object_id) as Table_name,a.name StatsName,a.stats_id,a.auto_created,a.user_created,c.name as Stats_Column from sys.stats a
INNER JOIN sys.stats_columns b on a.object_id=b.object_id and a.stats_id=b.stats_id
INNER JOIN sys.columns c on b.object_id=c.object_id and b.column_id=c.column_id
where a.object_id=object_id('SomeTableName')

-> Removing the where clause will display all statistics from all tables on the database.

Thank You,
Vivek Janakiraman

Disclaimer:
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided “AS IS” with no warranties, and confers no rights

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s