sp_who

Description

Reports information about all current Adaptive Server users and processes or about a particular user or process.

Syntax

sp_who [loginame | "spid"]

Parameters

loginame

is the Adaptive Server login name of the user you are requesting a report on.

spid

is the number of the process you are requesting a report on. Enclose process numbers in quotes (Adaptive Server expects a char type).

Examples

Example 1

Reports on the processes running on Adaptive Server. Process 11 (a select on a table) is blocked by process 8 (a begin transaction followed by an insert on the same table). For process 8, the current loginame is “robert”, but the original loginame is “sa”. Login “sa” executed a set proxy command to impersonate the user “robert”:

sp_who

fid spid  status    loginame origname hostname blk_spid  dbname 
       cmd                blk_xloid
--- ----- --------   -------- -------- -------- -------  ------ 
       ------------------ ---------
  0    1  recv sleep  bird     bird     jazzy    0       master 
       AWAITING COMMAND   0x0000ed92
  0    2  sleeping    NULL     NULL              0       master 
       NETWORK HANDLER    0x0000ed92
  0    3  sleeping    NULL     NULL              0       master 
       MIRROR HANDLER     0x0000ed92
  0    4  sleeping    NULL     NULL              0       master 
       AUDIT PROCESS      0x0000ed92
  0    5  sleeping    NULL     NULL              0       master 
       CHECKPOINT SLEEP   0x0000ed92
  0    6  recv sleep  rose     rose     petal    0       master 
       AWAITING COMMAND   0x0000ed92
  0    7  sleeping    NULL     NULL     actor    0    sybsystemdb
       ASTC HANDLER       0x0000ed92
  0    8  running     robert   sa       helos    0       master 
       SELECT             0x0000ed92
  0    9  send sleep  daisy    daisy    chain    0       pubs2  
       SELECT             0x0000ed92
  0   10  alarm sleep lily     lily     pond     0       master 
       WAITFOR            0x0000ed92
  0   11  lock sleep  viola    viola    cello    8       pubs2  
       SELECT            0x0000ed92

Example 2

Reports on the processes being run by the user “victoria”:

sp_who victoria

Example 3

Reports what Adaptive Server process number 17 is doing:

sp_who "17"

Example 4

Reports on the processes running on Adaptive Server. Although no user processes other than sp_who are running, the server still shows activity. During idle cycles, the housekeeper task moves dirty buffers into the buffer wash region:

sp_who

fid spid  status    loginame origname hostname blk_spid dbname
       cmd              block_xloid
---- ---- --------  -------- -------- -------- -------- ------
       ---------------- -----------
  0    1  running   sa       sa       helos    0        master 
       SELECT             0
  0    2  sleeping  NULL     NULL              0        master 
       NETWORK HANDLER    0
  0    3  sleeping  NULL     NULL              0        master 
       DEADLOCK TUNE      0
  0    4  sleeping  NULL     NULL              0        master 
       MIRROR HANDLER     0
  0    5  sleeping  NULL     NULL     actor    0        master
       ASTC HANDLER       0
  0    6  sleeping  NULL     NULL              0        master 
       CHECKPOINT SLEEP   0
  0    5  sleeping  NULL     NULL              0        master 
       HOUSEKEEPER       0

Usage

Permissions

Any user can execute sp_who.

See also

Commands kill

System procedures sp_familylock, sp_lock