Aug 8, 2012

Check how many users are logged into SQL Server

Have you ever wondered how to check how many users are logged in to the SQL Server? You must have right' so here is the solution to find it out. Execute any one of the below query in your SQL Server.

select * from sys.sysprocesses
EXEC sp_who
EXEC sp_who2

To know more about eh sysprocesses go to this link:

You can also check the active connections for each Database in your SQL Server. To do so execute the following query.

SELECT db_name(dbid) as DatabaseName, count(dbid) as NoOfConnections,
loginame as LoginName
FROM sys.sysprocesses
WHERE dbid > 0
GROUP BY dbid, loginame

No comments:

Post a Comment