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 table 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..sysprocessesalso provides additional information such as the login_time, program_name and others. For full details of the
master..sysprocessestable refer to SQL Server Books Online.
Hope this helps.