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!