Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k points)

I am using SQL Server 2008 Enterprise. I want to see any active SQL Server connections, and the related information of all the connections, like from which IP address, connect to which database or something.

Are there existing commands to solve this issue?

1 Answer

0 votes
by (40.7k points)

Try below code:

SELECT DB_NAME(dbid) as DBName,

COUNT(dbid) as NumberOfConnections,loginame as LoginName

FROM sys.sysprocesses

WHERE dbid > 0

GROUP BY dbid, loginame;

Or you can refer to Microsoft’s documentation of  sys.sysprocesses

Browse Categories

...