Skip to content
 

A Better sp_who2 using DMVs (sp_who3)

You are currently browsing comments. If you would like to return to the full story, you can read the full entry here: “A Better sp_who2 using DMVs (sp_who3)”.

13 Comments

  1. Edward Pinto says:

    This worked like a Charm Derek.. I was able to pinpoint the offender really quick and nip it in the bud.

  2. Sean says:

    This script/sp rocks!

    Thanks!

  3. Peter says:

    Nice work but it only seems to find connections to the master,tempdb databases…

    EXEC SP_WHO2 gives me about 100 result and your query only 20…

    • Derek Dieter says:

      Hi Peter,

      This is because this script only shows active connections. Personally I prefer this because when troubleshooting, I can immediately see how busy the server is just by the sheer number of results. sp_who2 will show all connections and I need to figure out which ones are asleep. To change this to show sleeping connections, simply join the sessions table first, then left join on the dm_exec_requests

      Derek

  4. Steve says:

    Nice. I have a long running Select (over 50 minutes). I’m running sp_who3 with sp_who2 in the same window. who2 DiskIO column is increasing each time I rerun, but who3 IOReads and IOWrites are static at the same values as the first time I ran it in this SSMS window. I would have expected who3 to change. I can see who3 changing ElapsedMS. CPUTime looks frozen too. Is this behaving as intended? Thanks for the tool!

  5. Have you tried my Who is Active procedure?

    http://tinyurl.com/WhoIsActive

    It is designed with similar goals but has a lot more functionality and several options to help you find the information you need, including the ability to only return active sessions, only return sessions that are either active or have an open transaction, or to return all sessions.

  6. adonetok says:

    It is ok in sql 2008 but can not save in sql 2000, got an error:

    Incorrect syntax near the keyword ‘OUTER’.

    (OUTER APPLY sys.dm_exec_sql_text(er.sql_handle) st)

  7. eatdirt says:

    Excellent example, this is a big help for me in our monitoring application.

    • Derek D. says:

      Great, glad this helped. I have considered altering this to include all sessions and not just active ones. I may add an additional example for that one. This helps me sometimes but I still find myself using sp_who2 a lot.

  8. [...] fix. It is likely you have a run away query. The first thing you want to do is run sp_who2 (or sp_who3) and look for connections that have a SPID > 50 with abnormally high CPU time. The CPU time shown [...]

post a comment OR Post Your Question on our ASK! Community!