Posts Tagged ‘Get all active connection for each database in Sql serv’

Hello Friends one requriment face last days from my boss was he said me that get all active connection in any database in sql server. mean give me list of all user which are currently connected to the our live database.

so fullfill this requriment with below solution so please write this query it will make your boss happier also

this query is for all database on server.

SELECT db_name(dbid) as DatabaseName, count(dbid) as NoOfConnections,
loginame as LoginName
FROM sys.sysprocesses
WHERE dbid > 0
GROUP BY dbid, loginame

please tell your boss and get increment in your salary.