SELECT name
AS index_name,type, sys.indexes.type_desc,sys.indexes.object_id,
STATS_DATE(OBJECT_ID, index_id) AS StatsUpdated,
datediff(day, STATS_DATE(OBJECT_ID, index_id) ,getdate()) AS DaysOld
FROM sys.indexes
WHERE OBJECT_ID in (SELECT sys.tables.object_id from sys.tables
where sys.tables.type = 'U')
) as t1
where DaysOld is not NULL --AND DaysOld <> 0
order by DaysOld desc

EXEC sp_updatestats (to update Statistic at Database level)

No comments:
Post a Comment