Search This Blog

Friday, December 14, 2012

sp_who SQL Server

SQL Server > System Stored Procedures > sp_who

Returns information about current users, sessions, and processes.
 Syntax: sp_who [ loginame | sessionID | 'ACTIVE' ]  

Example
Find the spid and kill user process.

exec sp_who

Results:
spid ecid status         loginame hostname    blk dbname                    cmd request_id
53   0       suspended sa            pc01            0    db                             DELETE 0

kill 53


sp_who2 is undocumented and unsupported. sp_who2 adds some extra columns which sp_who does not include.

EXEC sp_who2