SQL Query to Get Number of Active Connections

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

Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.

Latest Blogs