This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing a script for getting a total number of connected sessions of a SQL Server Database.
There are multiple ways for getting the information of connected users, but I am sharing one of the handy DBA scripts which they can use in their day to day work.
Check the below script:
1 2 3 4 5 6 7 8 |
select db_name (resource_database_id) as DatabaseName ,count (*) as TotalSessions from sys.dm_tran_locks where resource_type = 'DATABASE' and db_name (resource_database_id) = 'Database_Name' group by db_name (resource_database_id) order by db_name (resource_database_id) |
Leave a Reply