Earlier I had written a blog post about SQL SERVER – Representing sp_who2 with DMVs and SQL SERVER – Inserting sp_who2 Into a Table. One of my clients asked me a follow-up question in the Comprehensive Database Performance Health Check. The question was about sp_Who2 parameters. Let us learn about them today.
Just like sp_who the stored procedure sp_who2 also accepts similar parameters. Let us see a few of the examples.
User Specific Process via Parameters
USE master; GO EXEC sp_who 'sqlauthority'; GO
Display Specific Session ID
USE master; GO EXEC sp_who '102'; GO
Display Only Active Sessions
USE master; GO EXEC sp_who 'active'; GO
Well, that is for today. Let me know if you know any other trick with sp_who2. While there are many advanced scripts out there, I still see lots of users using the sp_who2 to gain additional insight into their system.
Here are a few recent blog posts on the same topic which you may find interesting:
- Slow Running Query – SQL in Sixty Seconds #146
- Sleeping vs Suspended Process – SQL in Sixty Seconds #122
- Recent Execution of Stored Procedure – SQL in Sixty Seconds #118
Let me know what you think of this blog post and if you want me to create a SQL in Sixty Seconds post for this video. If you have a similar script that you may find will be helpful to users, please do share it with me and I will post it on the blog with due credit to you.
You can always reach out to me via Twitter here.
Reference:Â Pinal Dave (https://blog.sqlauthority.com)