script to find when index was created

  • I was looking for the date value of when an index was created, there is no date field in sysindexes, and linking back to objects is not returing right value. Anyone know where to look?

  • I had the same question some days ago and only found that the index creation affected the column modify_date in sys.objects. If the index supports a constraint, you could query for the constraint create_date.

    By the way, you shouldn't be using sysindexes.

    From Books OnLine


    :exclamation: Important

    This SQL Server 2000 system table is included as a view for backward compatibility. We recommend that you use the current SQL Server system views instead. To find the equivalent system view or views, see Mapping SQL Server 2000 System Tables to SQL Server 2005 System Views. This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • if the index is a PK constraint the Create date is on sys.objects

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

  • For indices other than primary keys the answer is NO, the closest would be the date for the statistics

    😎

    SELECT

    I.object_id

    ,I.index_id

    ,I.name AS IDX_NAME

    ,OBJECT_NAME(I.object_id) AS OBJ_NAME

    ,STATS_DATE(I.object_id, I.index_id) AS IDX_STATS_DATE

    FROM sys.indexes I

    WHERE STATS_DATE(I.object_id, I.index_id) IS NOT NULL;

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply