Tables Last Accessed...

  • Hello,

    Does any one know of some T-SQL that returns a date time when a table was last accessed??? I need to clean up my SQL server and there are quite a number of tables that don't do anything.

    Cheers,

    Chris

  • I'd be interested in knowing this too.

    My thoughts are maybe the statistics (if auto-generated) will have a last accessed date for a table. I guess if a table doesn't have any records then it's obsolete.

    Maybe put a trigger on the tables to inform you of any usage, then get rid of the ones not used...

    Just my thoughts tho...

    Keith

    "It makes me want to run around the Server Room in a Super-Hero Costume"


    "It makes me want to run around the Server Room in a Super-Hero Costume"

  • Instead of a trigger you could run SQL profiler.

    Regards,

    Andy Jones

    .

  • Profiler is probably a better option. A trigger can't be put on a SELECT statement. However, some parsing is going to be required.

    K. Brian Kelley

    bkelley@sqlservercentral.com

    http://www.truthsolutions.com/

    K. Brian Kelley
    @kbriankelley

  • Hello,

    Thanks for your thoughts. I thought there would be some nice T-SQL to let me know when the table was last accessed without having to build up a history starting from today. If there was I would be able to happily remove the tables now.

    I'm using Profiler to build up that history now and will query it in around a month to see what it gives me.

    Thanks anyhow, always good to post here.

    Chris

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

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