Popular Posts

Friday, February 22, 2013

SQL SERVER – Find Statistics Update Date – Update Statistics | SQL Server Journey with SQL Authority

Wrong statistics can cause under estimation and spills ie the pages will be spilled from memory to IO and therefore can cause a lot of performance issues and applying queries in SQL Server .... To identify a list of all tables and indexes and the no o days their statistics is not updated, the following query can help ...



You can use the below query to find all the Tables and Index with number of days statistics being old
SELECT OBJECT_NAME(A.object_id) AS Object_Name, A.name AS index_name, STATS_DATE(A.OBJECT_ID, index_id) AS StatsUpdated ,
DATEDIFF(d,STATS_DATE(A.OBJECT_ID, index_id),getdate()) DaysOld
FROM sys.indexes A
INNER JOIN sys.tables B ON A.object_id = B.object_id
WHERE A.name IS NOT NULL
ORDER BY DATEDIFF(d,STATS_DATE(A.OBJECT_ID, index_id),getdate()) DESC
Thsi works fine with Both SQL Server 2005 and 2008



SQL SERVER – Find Statistics Update Date – Update Statistics | SQL Server Journey with SQL Authority:

'via Blog this'

No comments:

Post a Comment