Thursday 8 July 2010

Are my statistics up to date?

SELECT
   s.name   AS SchemaName
 , t.name   AS TableName
 , i.name   AS IndexName
 , i.type_desc AS IndexType
 , STATS_DATE(i.[object_id], i.index_id) AS StatisticsDate
FROM    sys.objects t  
INNER JOIN sys.indexes i  ON i.[object_id] = t.[object_id]
INNER JOIN sys.schemas s ON t.[schema_id] = s.[schema_id] 
WHERE i.name IS NOT NULL AND s.name <> 'sys'
ORDER BY STATS_DATE(i.[object_id], i.index_id)  , t.name, i.type 

No comments: