SQL SERVER – How to See Active SQL Server Connections For Database

·

·

How many user are connected to my database? Or How do I know which user is connected to my database with how many connection?

 

–#==E.g.1==#–

 

SELECT

DB_NAME(dbid) as DBName,

COUNT(dbid) as NumberOfConnections,

loginame as LoginName

FROM

sys.sysprocesses

WHERE

dbid > 0

GROUP BY

dbid, loginame

 

 

 

–#==E.g.2==#–

 

SELECT DB_NAME(dbid) AS DBName,

COUNT(dbid) AS NumberOfConnections,

loginame

FROM    sys.sysprocesses

GROUP BY dbid, loginame

ORDER BY DB_NAME(dbid)

GetConnectionCounts



Leave a Reply

Your email address will not be published. Required fields are marked *