How to Check Opened Connection in SQL Server





5.00/5 (2 votes)
Here is the code snippet to check how many database connections are opened in SQL Server.
Introduction
Sometimes, we need to know how many database connections are opened in SQL Server. So here is the code snippet that we can use to get a number of opened connections per database.
SELECT
[DATABASE] = DB_NAME(DBID),
OPNEDCONNECTIONS =COUNT(DBID),
[USER] =LOGINAME
FROM SYS.SYSPROCESSES
GROUP BY DBID, LOGINAME
ORDER BY DB_NAME(DBID), LOGINAME
When you run the above code, you will get a result something like below:
Enjoy reading!