Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I see active SQL Server connections?

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?

like image 482
George2 Avatar asked Aug 08 '09 09:08

George2


2 Answers

You can use the sp_who stored procedure.

Provides information about current users, sessions, and processes in an instance of the Microsoft SQL Server Database Engine. The information can be filtered to return only those processes that are not idle, that belong to a specific user, or that belong to a specific session.

like image 121
mmx Avatar answered Sep 22 '22 08:09

mmx


SELECT      DB_NAME(dbid) as DBName,      COUNT(dbid) as NumberOfConnections,     loginame as LoginName FROM     sys.sysprocesses WHERE      dbid > 0 GROUP BY      dbid, loginame ; 

See also the Microsoft documentation for sys.sysprocesses.

like image 24
Syed Umar Ahmed Avatar answered Sep 22 '22 08:09

Syed Umar Ahmed