Ad Code

How to check total number of sessions on a SQL Server - SQL Server DBA Tutorial

How to check all active connection on a SQL Server - SQL Server DBA Tutorial

In this article, I'll share a script for monitoring all active sessions on a SQL Server database.

There are many methods for getting connected users' information, however I am providing one of the useful DBA scripts that they can apply in their daily work.

 

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)

 

See Below for Results:


 





Post a Comment

0 Comments

Close Menu