The “SHOW PROCESSLIST;” equivalent in Microsoft SQL-Server

We, MySQL users, are spoiled. We don’t realize it, until we have a Microsoft SQL-Server in front of us. For MySQL, you have the following wonderful command.

mysql > SHOW PROCESSSLIST;
mysql > SHOW FULL PROCESSLIST;

That will list all active connections, the query being executed and the state (waiting for MySQL to process it, sending data, sleeping, … ).

If you’re in SQL Server Management Studio, you can do the following via “New Query”.

sp_who;

Or

sp_who2;

Not quite the same, but it also shows you the connected users and the state of that connection. “sp_who;” will list all users, and “sp_who2;” will increase the output with things like CPU time, Disk IO, …