Tuesday, October 5, 2010

SQL Server Number of Database Connections

The following piece of SQL can be used to find the number of connections currently active on all databases in SQL Server:
SELECT db_name(dbid) as DatabaseName, count(dbid) as NoOfConnections,
loginame as LoginName
FROM sys.sysprocesses
WHERE dbid > 0
GROUP BY dbid, loginame