Monday, March 29, 2010

SQL Index Creation Date

A while back I was trying to figure out a performance problem in SQL, eventually it was traced to an index that improved performance on other queries but the specific query was rarely used and it wasn't tested, this query helped me to figure out which index was added when.

Select OBJECT_NAME( sys.indexes.object_id ) AS TableName, Name as IndexName, 
STATS_DATE ( object_id , index_id ) as IndexCreatedDate
From sys.indexes 
order by STATS_DATE ( object_id , index_id ) desc