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 into next blog.
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.
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 IndexType, TableType=Case When OBJECTPROPERTY(OBJECT_ID,'IsUserTable')=0 Then 'SystemTable' When OBJECTPROPERTY(OBJECT_ID,'IsUserTable')=1 Then 'UserTable' END, STATS_DATE(OBJECT_ID, index_id) AS StatsUpdatedDate
FROM sys.indexes
Where OBJECTPROPERTY(OBJECT_ID,'IsUserTable')=1
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.
No comments:
Post a Comment