Find active SQL Server connections for Database


Sometimes we need to check the connection for the database, using the following query we can get the total connection, login Name with Database Name.

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)

The result will be shown below.

DataBaseName                 TotalConnections            LogName
-------------------------------------------------
MYTESTDB                          3                                dkadmin
MYDKDB                             119                             dkadmin
MYDKDB                             10                               sa     
master                                17                              sa    
master                                12                              dkadmin
msdb                                  3                                NT SERVICE\SQLSERVERAGENT
                 

NUnit : Introduction

There are several unit test tools in the market, but one of them is NUnit, the most popular tool for doing unit testing. So in this tutorial...