Statistics Updated Date | SansSQL

Friday, April 30, 2010

Statistics Updated Date

Statistics in SQL Server refers specifically to information that the server collects about the distribution of data in columns and indexes. More information about Statistics on How to Create, Drop and update Statistics are covered here.
In this post, we will see how to retrieve the information on when a Statistics was last updated.
To retrieve this information, run the below query on one of the database.
SELECT OBJECT_NAME(OBJECT_ID) AS TableName, name AS IndexName, Type_desc AS IndexTypeTableType=Case When OBJECTPROPERTY(OBJECT_ID,'IsUserTable')=0 Then 'SystemTable' When OBJECTPROPERTY(OBJECT_ID,'IsUserTable')=1 Then 'UserTable' ENDSTATS_DATE(OBJECT_ID, index_id) AS StatsUpdatedDate 
FROM sys.indexes 
Where OBJECTPROPERTY(OBJECT_ID,'IsUserTable')=
Order by TableName

This query will list the indexes present on all of the user tables in a particular database and when their Statistics was last updated.

Ads