Home  »  Code Snippets  »  SQL Server  »

How to determine total number of open/active connections in ms sql server

 Posted By : Manoranjan SahooPosted Date : 06/12/2014 02:00:44 PM Category : SQL Server Points : 6

Below code will show the number of connections per each DB:
SELECT 
    DB_NAME(dbid) as DBName, 
    COUNT(dbid) as NumberOfConnections,
    loginame as LoginName
FROM
    sys.sysprocesses
WHERE 
    dbid > 0
GROUP BY 
    dbid, loginame
To know the total number of connection use below code :
SELECT 
    COUNT(dbid) as TotalConnections
FROM
    sys.sysprocesses
WHERE 
    dbid > 0


Responses
No responses found for this thread. Be the first to respond this thread.
Post Reply
Login to post Response.