The parameters of sp_who2 are one optional value that can be a session ID, the word active or a login name. This post counts the rows each form returns, shows that the login form does not filter, and explains the errors.
Disable Row Goal in SQL Server: When the Hint Helps and When It Hurts
To disable row goal for one query, add the DISABLE_OPTIMIZER_ROWGOAL hint to it. This post builds a table where the row goal chooses a bad plan, shows the reads with and without the hint, and then shows a table where the row goal wins.
List All Sessions – SQL in Sixty Seconds #148
One of the most frequent questions which I receive from my client is about activity going inside SQL Server and how to list all sessions.
Attach an In-Memory Database With T-SQL: Include the Container
To attach an In-Memory database with T-SQL, use CREATE DATABASE with FOR ATTACH and list the data file, the log file and, when it moved, the container folder. This post builds a demo database, detaches it and attaches it twice. It also shows which rows survive.
SQL SERVER – Attach a Database with T-SQL
To attach a Database with T-SQL, I use CREATE DATABASE … FOR ATTACH. A customer asked about attaching existing data and log files.
Capture sp_who2 Output Into a Table With INSERT EXEC
To capture sp_who2 output, create a table with matching columns and fill it with INSERT EXEC. This post builds the table, captures the session list three times with a time stamp, and shows the two errors that stop the method.
DMV Version of sp_who2: A Cleaner Session List
A DMV version of sp_who2 returns the same session details from documented views and leaves out the system tasks. This post builds the query, shows why the old spid above 50 filter fails, and stores the result in a temporary table.







