Sql Server: When was the last time STATISTICs were updated on a table
- Posted by Sqltimes
- On November 4, 2012
- 0 Comments
This is one of the most frequent questions during performance tuning (or during the maintenance plan discussions). There is a quick way to check this for all the STATISTICS on all tables. The function STATS_DATE returns the date when the stats were recomputed.
Example:
[sourcecode language=”sql”]
SELECT OBJECT_NAME(object_id) AS [Table_Name]
, STATS_DATE(object_id, stats_id) AS [State_Updated_Date]
, name AS [Stats_Name]
FROM sys.stats
WHERE OBJECT_NAME(object_id) NOT LIKE ‘sys%’
ORDER BY STATS_DATE(object_id, stats_id) DESC
[/sourcecode]
The function STATS_DATE() takes two parameters: object_id of the table and stats_id of the statistic.
Hope it helps,
0 Comments