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. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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:

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

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

Your Answer


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.