sp_who vs sp_who2 vs sp_whoisactive in SQL Server

🔧Part of the DBA-Tools Project, copy/paste SQL Server scripts and health checks.Related pillar: Performance & Troubleshooting

Something is slow or blocked and you need to see what is running right now. sp_who, sp_who2 and sp_whoisactive all answer that, at very different depths. The first ships documented, the second ships undocumented but better, and the third is a free community procedure that most working DBAs treat as the real answer.

Below is what each one shows, the quirks worth knowing, and which one to reach for when something is blocking.


The Comparison, Up Front

 sp_whosp_who2sp_whoisactive
Ships with SQL ServerYes, documentedYes, undocumentedNo, free install
ShowsAll sessions, system includedAll sessions + CPU, IO, last batch, programActive sessions plus idle ones holding a transaction, full query text, plans, waits, tempdb use
Blocking infoblk columnBlkBy columnBlocking chains, with the blocker’s SQL
Reach for it whenIt is all you haveQuick look on any server, zero installAny real investigation

sp_who: The Documented Baseline

sp_who lists every process on the instance at the moment you run it: login, host, database, and the command type being run (not the SQL text itself). Most of what you see on a quiet instance is SQL Server talking to itself rather than anything you started. Do not judge that by the session ID.

The old rule that 50 and below is system does not hold on current builds: on the SQL Server 2025 instance used for this post there were 55 system sessions with IDs as high as 76, five of them above 50, and the lowest user session was 52. The reliable test is is_user_process in sys.dm_exec_sessions.

EXEC sp_who;

-- narrow it to one login
EXEC sp_who 'sa';
sp_who output in SSMS showing spid, status, loginame and cmd for every session, with background tasks listed alongside a user session

It answers “who is connected”, and not much more (sp_who on Microsoft Learn lists every column). If what you actually want is to end a session, that job is covered in How to Kill a SPID in SQL Server.


sp_who2: Undocumented, and Better

sp_who2 is the version everyone actually types. It is undocumented, Microsoft could change or drop it without notice, and it has stayed put for decades anyway. On top of sp_who it adds CPUTime, DiskIO, LastBatch, ProgramName and the BlkBy column, which is the quick blocking read: a number in BlkBy is the SPID doing the blocking.

EXEC sp_who2;

-- active sessions only
EXEC sp_who2 'active';
sp_who2 'active' output in SSMS with CPUTime, DiskIO, LastBatch and ProgramName columns and suspended INSERT sessions from Agent job steps

Two quirks worth knowing, both still true on SQL Server 2025: the SPID column appears twice in the output (once at each end of the row), and the results cannot be filtered or sorted directly since it is a procedure. The fix for the second one is inserting the output into a temp table and querying it like anything else, covered in Log and Filter sp_who2 Results.

sp_who2 also earned a spot in the SSMS keyboard shortcuts world: Ctrl+1 runs sp_who by default, and the same query-shortcut mechanism can put sp_who2 or any procedure on a key.


sp_whoisactive: The One DBAs Install Everywhere

sp_whoisactive, created by Adam Machanic, is a free stored procedure and the de facto standard for “what is running right now”. Where the built-ins show you session rows, this shows you the investigation: the full SQL text of what each session is running, execution plans on request, wait information, tempdb allocations, and blocking presented as a chain rather than a number you have to chase.

By default it shows active user sessions, plus any idle session that still holds an open transaction, and leaves out system sessions and other idle connections. That second part matters: an idle session with an uncommitted transaction is the classic blocker, and sp_who2 would show it as just another sleeping row.

-- install: run the script from whoisactive.com, then:
EXEC sp_whoisactive;

-- with query plans
EXEC sp_whoisactive @get_plans = 1;
sp_whoisactive with @get_plans = 1 in SSMS showing reads, writes, clickable query_plan links and blocking_session_id for the active sessions
💾It is one file, and installing it takes a minute. Open sp_WhoIsActive.sql, copy the whole thing, and run it once per instance. Install it in master: the sp_ prefix means EXEC sp_whoisactive; then works from any database, which is how its author intends it and how every example here calls it. If your estate keeps tooling out of system databases, a DBA database works too, but then every call is the full name, EXEC DBA.dbo.sp_whoisactive;, including any SSMS shortcut.

Seeing Blocking With Each One

A simple way to compare all three: create some blocking on a test instance. Open one query window, start a transaction that updates a row, and leave it uncommitted. In a second window, select from the same table. Now:

  • sp_who shows the second session with a non-zero blk value.
  • sp_who2 shows the blocker’s SPID in BlkBy.
  • sp_whoisactive shows both sessions: the victim with its SQL, its wait and how long it has waited, and the blocker as sleeping with open_tran_count 1.

One catch on the blocker: for a sleeping session sql_text is the last batch it ran, not the statement that took the lock. If the application sent the UPDATE and a later SELECT as separate batches, you see only the SELECT. Add @get_locks = 1 to see the locks it holds, and treat a long-sleeping session with an open transaction as the suspect whatever its text says.

The first two tell you blocking exists. The third gets you to the session to deal with. For the fuller blocking workflow on this site, see How to Check Blocking SPIDs in SQL Server.


Frequently Asked Questions

Is it safe to rely on sp_who2 if it is undocumented?

For interactive use, yes, it has been stable for decades. For anything automated or scripted, build on the documented DMVs (sys.dm_exec_sessions, sys.dm_exec_requests) instead. Undocumented means no compatibility promise.

Does sp_whoisactive need sysadmin?

No. It needs VIEW SERVER STATE to see other sessions’ activity, the same permission the DMVs behind it require. Granting that is covered in Grant VIEW SERVER STATE in SQL Server.

Why does sp_who show so many sessions I did not create?

Most of them are SQL Server’s own background tasks rather than anything you started. Do not go by the number: on a SQL Server 2025 instance checked for this post, system sessions ran as high as 76 and the lowest user session was 52, so the old 50-and-below rule would have misread it. Filter on sys.dm_exec_sessions.is_user_process = 1 instead. They are normal, always present, and never candidates for KILL.


Summary

sp_who is the documented baseline, sp_who2 is the undocumented upgrade everyone actually uses for a quick look, and sp_whoisactive is the free install that turns “who is connected” into “here is exactly what is running, what it is blocked by, and its plan”. Use the built-ins for a glance on a server you have never touched; install sp_whoisactive everywhere you are responsible for.


Related

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *