Skip to content

Commit fc16d14

Browse files
Merge fix/loghunter-custom-message-escape into dev
2 parents d92cd42 + e768943 commit fc16d14

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

sp_LogHunter/sp_LogHunter.sql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,13 @@ BEGIN
491491
(
492492
VALUES
493493
(
494-
N'"' + @custom_message + '"',
494+
/* xp_readerrorlog search strings are wrapped in double quotes
495+
(see the #search.command computed column), so any literal "
496+
inside the user-supplied @custom_message must be doubled to
497+
avoid closing the argument early and producing an
498+
"Incorrect syntax near '+'" error when sp_executesql parses
499+
the generated batch. */
500+
N'"' + REPLACE(@custom_message, N'"', N'""') + N'"',
495501
N'"' + CONVERT(nvarchar(10), DATEADD(DAY, @days_back, SYSDATETIME()), 112) + N'"',
496502
N'"' + CONVERT(nvarchar(30), @start_date) + N'"',
497503
N'"' + CONVERT(nvarchar(30), @end_date) + N'"'

0 commit comments

Comments
 (0)