Cry How to...

List all currently connected users


The simplest way to list all users and processes is to use the system stored procedure:

sp_who

to list all active users:

sp_who 'active'

to list details about a particular user:

sp_who 'login-name'

the same information (and more) can be found by interrogating the system table master..sysprocesses, for example the following is equivalent to 'sp_who':

select spid, status, loginame, hostname, blocked, db_name(dbid), cmd from master..sysprocesses

but the table master..sysprocesses also provides additional information such as the login_time, program_name and others. For full details of the master..sysprocesses table refer to SQL Server Books Online.


These notes have been tested against SQL Server 7.



About the author: is a dedicated software developer and webmaster. For his day job he develops websites and desktop applications as well as providing IT services. He moonlights as a technical author and consultant.