Blog

SQL Query to Get Number of Active Connections

Posted by Veena Sarda Blogs | SharePoint 2013 Sep 13, 2013
The following query gets number of active SQL Connections.

Many a times during debugging or performance analysis it is required to understand how many active connections are made to the SQL Server SharePoint databases. The following query gets number of active SQL Connections.

SELECT

                hostname AS [Client],

                program_name AS [Client Application],

                DB_NAME(dbid) AS [Database Name],

                COUNT(dbid) AS [Number of Connections],

                UPPER(loginame) AS [Login or UserID]

FROM

                sys.sysprocesses

WHERE

                dbid > 0 AND DB_NAME(dbid) NOT IN ('master','model','msdb','tempdb')

GROUP BY

                hostname,

                program_name,

                dbid,

                loginame

ORDER BY

                [Number of Connections] desc

You will see output as shown in figure below

Number of SQL Connections.png

COMMENT USING
PREMIUM SPONSORS
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.
SPONSORED BY
  • MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.