SQL SERVER – Find Total Sessions by Database

Today we will see a very simple script that I often use during my  Comprehensive Database Performance Health Check. Let us find Total Sessions By Database.

SELECT DB_NAME(resource_database_id) AS DatabaseName, COUNT(*) AS TotalSessions
FROM sys.dm_tran_locks
GROUP BY DB_NAME(resource_database_id)
order by db_name(resource_database_id)

That’s it. It is a very simple script that will list all the sessions for a particular database with a database name and total sessions.

Here is the six-part blog post series I have written based on my last 10 years of experience helping with the Comprehensive Database Performance Health Check. I strongly recommend you to read them as they walk you through my business model.

Here are my few recent videos and I would like to know what is your feedback about them. Do not forget to subscribe SQL in Sixty Seconds series.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

Exit mobile version