How do I see active SQL Server connections?
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.
SELECT DB_NAME(dbid) as DBName, COUNT(dbid) as NumberOfConnections, loginame as LoginNameFROM sys.sysprocessesWHERE dbid > 0GROUP BY dbid, loginame;
See also the Microsoft documentation for sys.sysprocesses.
Apart from sp_who
, you can also use the "undocumented" sp_who2
system stored procedure which gives you more detailed information. See Difference between sp_who and sp_who2.