Sunday, 8 November 2015

T-SQL to check whether the statistics of tables are up to date or not

With the help of below T-SQL we can check whether the statistics of tables are up to date or not

 SELECT distinct OBJECT_NAME(s.object_id) AS [ObjectName]
      ,s.[name] AS [StatisticName]
      ,STATS_DATE(s.[object_id], [stats_id]) AS [StatisticUpdateDate]
FROM sys.stats s join sys.objects o on s.object_id=o.object_id
where o.type='U' and STATS_DATE(s.[object_id], [stats_id]) is not null;

Cheers,

No comments:

Post a Comment