Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Is there some SQL that I can use in order to find out which databases on the Server haven't been used recently? I need to find the ones that are no longer used and detach them.

share|improve this question
    
possible duplicate of How can I tell if a SQL Server database is still being used? –  Martin Smith Feb 11 '12 at 19:34
add comment

2 Answers

up vote 2 down vote accepted

You can gather some info from the index usage stats DMV (unless your databases are full of tables sans indexes). Aaron Bertrand has an article here which might be of interest to you: http://goo.gl/twAlh

share|improve this answer
    
good idea. I clean forgot about that –  gbn Feb 9 '12 at 16:27
add comment

No, unless you

  • logged access in your tables
  • had a trace (SQL Profiler) running
  • have a logon trigger
  • ...

You have to explicitly monitor this somehow.

If you need to do it now, you could make the database single user and see who calls...

share|improve this answer
    
Thanks - I guess SQL doesn't track when a database was last used. –  Neil Knight Feb 9 '12 at 10:56
    
Take @yogirk's answer, subject to provisos in the linked article –  gbn Feb 9 '12 at 16:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.