Dec 15, 2014

Find active SQL Server connections for Database

Run below script
SELECT DB_NAME(DBID) AS DataBaseName,
COUNT(DBID) AS TotalConnections,
loginame AS LogName
FROM    sys.sysprocesses
GROUP BY DBID, loginame
ORDER BY DB_NAME(DBID)

Result will be show like below.
DataBaseName                 TotalConnections            LogName
-------------------------------------------------
MYTESTDB                          3                                dkadmin
MYDKDB                             119                             dkadmin
MYDKDB                             10                               sa     
master                                17                              sa    
master                                12                              dkadmin
msdb                                  3                                NT SERVICE\SQLSERVERAGENT