CODE: connected to SQL server

SELECT DB_NAME(dbid) AS [Database Name], COUNT(dbid) AS [No Of Connections], loginame AS [Login Name]
FROM sys.sysprocesses
WHERE dbid > 0
GROUP BY dbid, loginame;