How to determine if a DB is currently being used

  • Hi - I'm looking for advice regarding the best & quickest way to establish whether or not a SQL2012 DB is being used.

    Many thanks

    Dax

  • As in is a user connected? Or has anyone been running queries. Those are two different things.

    I believe when someone connects, sp_who2 shows they are in the database, and I believe there is a shared lock.

    If you want to know if anyone has used the database in the last xxx days, you likely need an Extended Event trace looking for any activity in that database.

  • You can have a look at sys.dm_db_index_usage_stats() to see if there have been any reads or writes since the last time the SQL Server Service was started.

    Once you've decided that no on is using it, don't just drop it.  Just take it offline and wait for 6 weeks to see if the proverbial phone rings.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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