SELECT OBJECT_NAME(id), name, STATS_DATE(id, indid), rowmodctr FROM sys.sysindexes

WHERE STATS_DATE(id, indid)<=DATEADD(DAY,-1,GETDATE())

AND rowmodctr>0 AND id IN (SELECT object_id FROM sys.tables) order by rowmodctr desc;

 

SELECT ‘UPDATE statistics dbo.’ + OBJECT_NAME(id) FROM sys.sysindexes

WHERE STATS_DATE(id, indid)<=DATEADD(DAY,-1,GETDATE())

AND rowmodctr>0 AND id IN (SELECT object_id FROM sys.tables)and name not like ‘_WA_%’;