When were the indexes last rebuilt?

  • Hi everyone,

    Just curious if anyone has a script to see when were the indexes last rebuilt in a database? I've a query which uses STATS_DATE ( A.id , indid ) function. I think it gives the statistics updated date but not the index created date.

    Thanks,

    Sunil.

  • This will return the time indexes were last updated:

    Whoops:

    STAT_DATE Returns the date that the statistics for the specified index were last updated.

    Edited first line of text to:

    This will return the time indexes statistics were last updated

    SELECT 'Index Name' = i.name, OBJECT_NAME(i.id) AS 'Table Name',

    Case Indid

    WHEN 1 THEN 'Clustered'

    ELSE 'Non-clustered'

    End 'Type',

    'Last Updated' = STATS_DATE(i.id, i.indid),rowmodctr AS

    '# Rows inserted deleted or updated', i.keys

    FROM sysobjects o, sysindexes i

    WHERE o.id = i.id AND (o.type <> 'S' AND indid <> 0 AND indid <> 255)

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

Viewing 2 posts - 1 through 1 (of 1 total)

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