In SQL Server, we may sometimes need to check which machine has established a connection and how many connections are being made. In today’s article, we will discuss how to view such parameters.
For situations like this, you can use the query below.
1 2 3 4 5 6 7 8 9 10 11 |
SELECT DB_NAME(database_id) as [DB] , login_name , nt_domain , nt_user_name , status , host_name , program_name , COUNT(*) AS [Connections] FROM sys.dm_exec_sessions WHERE database_id > 0 -- OR 4 for user DBs GROUP BY database_id, login_name, status, host_name, program_name, nt_domain, nt_user_name; |