@@ -273,7 +273,8 @@ ALTER PROCEDURE dbo.sp_BlitzCache
273273 @MinutesBack INT = NULL ,
274274 @Version VARCHAR (30 ) = NULL OUTPUT ,
275275 @VersionDate DATETIME = NULL OUTPUT ,
276- @VersionCheckMode BIT = 0
276+ @VersionCheckMode BIT = 0 ,
277+ @KeepCRLF BIT = 0
277278WITH RECOMPILE
278279AS
279280BEGIN
@@ -483,7 +484,12 @@ IF @Help = 1
483484 UNION ALL
484485 SELECT N ' @VersionCheckMode' ,
485486 N ' BIT' ,
486- N ' Setting this to 1 will make the procedure stop after setting @Version and @VersionDate.' ;
487+ N ' Setting this to 1 will make the procedure stop after setting @Version and @VersionDate.'
488+
489+ UNION ALL
490+ SELECT N ' @KeepCRLF' ,
491+ N ' BIT' ,
492+ N ' Retain CR/LF in query text to avoid issues caused by line comments.' ;
487493
488494
489495 /* Column definitions */
@@ -2760,7 +2766,10 @@ SET PercentCPU = y.PercentCPU,
27602766 /* Strip newlines and tabs. Tabs are replaced with multiple spaces
27612767 so that the later whitespace trim will completely eliminate them
27622768 */
2763- QueryText = REPLACE (REPLACE (REPLACE (QueryText, @cr, ' ' ), @lf, ' ' ), @tab, ' ' )
2769+ QueryText = CASE WHEN @KeepCRLF = 1
2770+ THEN REPLACE (QueryText, @tab, ' ' )
2771+ ELSE REPLACE (REPLACE (REPLACE (QueryText, @cr, ' ' ), @lf, ' ' ), @tab, ' ' )
2772+ END
27642773FROM (
27652774 SELECT PlanHandle,
27662775 CASE @total_cpu WHEN 0 THEN 0
@@ -2816,7 +2825,10 @@ SET PercentCPU = y.PercentCPU,
28162825 /* Strip newlines and tabs. Tabs are replaced with multiple spaces
28172826 so that the later whitespace trim will completely eliminate them
28182827 */
2819- QueryText = REPLACE (REPLACE (REPLACE (QueryText, @cr, ' ' ), @lf, ' ' ), @tab, ' ' )
2828+ QueryText = CASE WHEN @KeepCRLF = 1
2829+ THEN REPLACE (QueryText, @tab, ' ' )
2830+ ELSE REPLACE (REPLACE (REPLACE (QueryText, @cr, ' ' ), @lf, ' ' ), @tab, ' ' )
2831+ END
28202832FROM (
28212833 SELECT DatabaseName,
28222834 SqlHandle,
0 commit comments