How to find out if a database is being used?

zoe Ohara 286 Reputation points
2021-05-12T09:56:13.133+00:00

Hi,
We have a database on a server, but we are unsure if anything is actually using it. Is there a way to monitor and store connections to the database? I was thinking of running it for about three weeks and if nothing connects, then taking it offline.

Thanks

SQL Server Other
{count} votes

Accepted answer
  1. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2021-05-12T21:58:31.693+00:00

    You can set up a trace or an X-Event session capturing RPC:Starting and SQL:BatchStarting and which is filtered for these databases. You may also have to filter out things like the Telemetry session if you are on SQL 2016 or later.

    Beware that even if the trace/X-Event session is filtered it will affect all processes, and if this is a system with very many, but, short commands, this can incur a significant overhead.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. CathyJi-MSFT 22,396 Reputation points Microsoft External Staff
    2021-05-13T03:28:15.093+00:00

    Hi @zoe Ohara ,

    >Is there a way to monitor and store connections to the database?

    You can try below method.

    •Capture login/connections over period of time
    •Observe index usage
    •Look at transaction count
    •Find dependencies with Jobs or other DBs

    Refer to the blogs Is This Database Being Used and 4 Lightweight Ways to Tell if a Database is Used to get more detail information.

    Please also check if this similar thread How can I tell if a SQL Server database is still being used could help you.


    If the response is helpful, please click "Accept Answer" and upvote it, as this could help other community members looking for similar queries

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.