Skip to content
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

Running sp_QuickieStore with @get_all_databases = 1 and @escape_brackets = 1 adds extra escapes to the query_text_search string. #380

Closed
ReeceGoding opened this issue Mar 23, 2024 · 3 comments

Comments

@ReeceGoding
Copy link
Contributor

ReeceGoding commented Mar 23, 2024

Version of the script
4.2.

What is the current behavior?
On a system with Query Store enabled on multiple non-system databases, run

EXEC sp_QuickieStore @get_all_databases = 1, @query_text_search = '[AnyStringStartingAndEndingWithSquareBrackets]', @escape_brackets = 1, @debug = 1;

Now look at the debug information in the debug table that has its first cell contain "procedure_parameters". It shows an interesting value in the "query_text_search" column. On a server with Query Store enabled on five non-system databases, the value in that cell is

%\\\\\[AnyStringStartingAndEndingWithSquareBrackets]\\\\\]%'

and on a server with twenty-three such databases, it shows the same, but with twenty-three \s on each side.

I take this as a sign that @get_all_databases = 1 and @escape_brackets = 1 don't work well together.

Furthermore, @escape_brackets does not appear in the readme on GitHub.

What is the expected behavior?

I presume that the number of \ shown in the cell in question should not be proportional to the number of non-system databases that have Query Store active.

Also, @escape_brackets should appear in the readme on GitHub.

Which versions of SQL Server and which OS are affected by this issue? Did this work in previous versions of our procedures?

I do not expect this to be version dependent.

@erikdarlingdata
Copy link
Owner

Oh I think I know what’s happening. There’s likely a += assignment of the bracket. I’m not home right now, but that seems the most likely scenario.

@ReeceGoding
Copy link
Contributor Author

I thought the same. I think I've got it figured out. I'll have a PR ready soon.

ReeceGoding added a commit to ReeceGoding/DarlingData that referenced this issue Mar 23, 2024
…nd hitting multiple databases

This is the smallest change that I could think of that would close erikdarlingdata#380. I have made an effort to be faithful to the original's style, but I must admit that I have not taken the time to become greatly familiar with this procedure. What I have done appears to work, but I have no idea if this is the best way.
@erikdarlingdata
Copy link
Owner

Closed via #381

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants