New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sp_BlitzWho - Add @GetOuterCommand to get contents of the inputbuffer per session_id (like sp_WhoIsActive) #2887
Comments
BrentOzarULTD#2887 An initial mock up for get outer command addition. Not a finished version this is just putting in place the main code less any log to table elements.
Thrown together a mock up , it's by no means finished but gives an idea of the intention. Works in ssms as long as you are not trying to log it to a table as i haven't gone any further in case this is an unwanted feature. :) |
BrentOzarULTD#2887 Replaced the dbcc inputbuffer loop with a cursor to reduce additional reads for retrieving the next session_id to execute. Added a new column to the output table 'outer_command' Added relevant code to allow log to table for both @GetOuterCommand - 0 and = 1
BrentOzarULTD#2887 Truncation errors were occurring when executing against sys.dm_exec_input_buffer as the event_info from this dmv is an NVARCHAR(MAX) versus DBCC INPUTBUFFER which is NVARCHAR(4000). Added a cast to ensure we are always getting a max of 4000 chars.
The cursor version of the inputbuffer code is only added to the dynamic SQL if sys.dm_exec_input_buffer does not exist otherwise this dmv is used as an outer apply. I initially thought that sys.dm_exec_input_buffer was not available in SQL 2012 but I have tested with SQL 2012 SP4 and the dmv is present and working. Depending on what version support we are currently providing for sp_BlitzWho and if we are really not feeling the cursor for this change we could perhaps skip the check if the dmv does not exist. I will park this where it is for now until we decide what the best approach is:
I guess it all depends how anti cursor we are feeling ha! |
I will give this a round of testing next week and get a PR submitted. |
Thanks for the pull request! I haven't tested on 2008/2008R2, but looks good so far. Merging into the dev branch, will be in the next release with credit to you in the release notes. |
Is your feature request related to a problem? Please describe.
New feature.
Describe the solution you'd like
Add a new parameter @GetOuterCommand which will grab the contents of DBCC inputbuffer and show as a new column called outer_command similar to sp_Whoisactive @get_outer_command = 1.
SQL 2012 and 2014 can get the input buffer from a call to dbcc inputbuffer per session_id whereas SQL2016+ would be able to obtain the same information from sys.dm_exec_input_buffer
Describe alternatives you've considered
Use sp_WhoIsActive which is amazing but so is sp_BlitzWho!
Are you ready to build the code for the feature?
Yep Happy to give this a go if it's something that people want?
The text was updated successfully, but these errors were encountered: