shivakb
6/14/2018 - 5:23 AM

Get Db Connections

This shows the number of connections per each DB

--This shows the number of connections per each DB
SELECT 
    DB_NAME(dbid) as DBName, 
    COUNT(dbid) as NoOfConnections,
    loginame as LoginName
FROM
    sys.sysprocesses
WHERE 
    dbid > 0
GROUP BY 
    dbid, loginame
    
    
    
--And this gives total connections:

SELECT 
    COUNT(dbid) as TotalConnections
FROM
    sys.sysprocesses
WHERE 
    dbid > 0