How to find number of usera connected to a SQL Server database
Views (3490)
I was having some intermittent problems with the connector. When I turned on the connector it would soon be unable to connect to the SQL database.
I was thinking it maybe be had something to do with the SQL server limiting connections.
The code below will show you the amount of connections and how many on each database. I found it in this forum post
SELECT
DB_NAME(dbid) as DBName,
COUNT(dbid) as NumberOfConnections,
loginame as LoginName
FROM
sys.sysprocesses
WHERE
dbid > 0
GROUP BY
dbid, loginame
And this gives the total:
SELECT
COUNT(dbid) as TotalConnections
FROM
sys.sysprocesses
WHERE
dbid > 0
Filed under: SQL Server, SQL Server 2012

This was originally posted here.
*This post is locked for comments