/* -- SQL Server 2008 and R2 Diagnostic Information Queries -- Glenn Berry -- June 2012 -- Last Modified: June 19, 2012 -- http://sqlserverperformance.wordpress.com/ -- http://sqlskills.com/blogs/glenn/ -- Twitter: GlennAlanBerry DESCRIPTION: Statistics last udpate Compatibility list: MSSQL2005 MSSQL2008 MSSQL2008R2 MSSQL2012 DOES NOT WORK MSSQL2000 Update Log: */ -- When were Statistics last updated on all indexes? (Query 48) SELECT o.name, i.name AS [Index Name], STATS_DATE(i.[object_id], i.index_id) AS [Statistics Date], s.auto_created, s.no_recompute, s.user_created, st.row_count FROM sys.objects AS o WITH (NOLOCK) INNER JOIN sys.indexes AS i WITH (NOLOCK) ON o.[object_id] = i.[object_id] INNER JOIN sys.stats AS s WITH (NOLOCK) ON i.[object_id] = s.[object_id] AND i.index_id = s.stats_id INNER JOIN sys.dm_db_partition_stats AS st WITH (NOLOCK) ON o.[object_id] = st.[object_id] AND i.[index_id] = st.[index_id] WHERE o.[type] = 'U' ORDER BY STATS_DATE(i.[object_id], i.index_id) ASC OPTION (RECOMPILE);