Cry How to...
List all currently connected users
The simplest way to list all users and processes is to use the system stored procedure:
to list all active users:
to list details about a particular user:
the same information (and more) can be found by interrogating the system
master..sysprocesses, for example the following is equivalent to '
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
master..sysprocesses table refer to SQL Server Books
These notes have been tested against SQL Server 7.
About the author: Brian Cryer 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.