Skip to content

Commit dc10aef

Browse files
BrentOzarclaude
andcommitted
sp_BlitzFirst CheckID 49: fix XPath and missing line break in Details output
Two fixes based on Copilot review feedback on PR BrentOzarULTD#3921: * Switch .value('text()[1]', 'nvarchar(max)') to .value(N'.[1]', N'NVARCHAR(MAX)') on all three Top-5 STUFF/FOR XML blocks. text()[1] returns only the first text node; when a program_name contains <, >, or & it gets entity-escaped and breaks the concatenation into multiple text nodes, so only the first row would appear. The new form matches the existing pattern used elsewhere in sp_BlitzFirst (see line 2487). * Insert @linefeed between each "Top 5 X:" header and the first row. The Top-5 strings are built with STUFF(..., 1, LEN(@linefeed), N'') so they don't start with a line break, which was running the first entry onto the header line. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent cd914b7 commit dc10aef

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

sp_BlitzFirst.sql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,7 +2732,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
27322732
) g
27332733
ORDER BY g.ConnectionCount DESC, g.ConnectionGroup
27342734
FOR XML PATH(''), TYPE
2735-
).value('text()[1]', 'nvarchar(max)'), 1, LEN(@LineFeed), N'');
2735+
).value(N'.[1]', N'NVARCHAR(MAX)'), 1, LEN(@LineFeed), N'');
27362736

27372737
SELECT @TopLogins = STUFF((
27382738
SELECT @LineFeed
@@ -2769,7 +2769,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
27692769
) g
27702770
ORDER BY g.ConnectionCount DESC, g.ConnectionGroup
27712771
FOR XML PATH(''), TYPE
2772-
).value('text()[1]', 'nvarchar(max)'), 1, LEN(@LineFeed), N'');
2772+
).value(N'.[1]', N'NVARCHAR(MAX)'), 1, LEN(@LineFeed), N'');
27732773

27742774
SELECT @TopApps = STUFF((
27752775
SELECT @LineFeed
@@ -2806,7 +2806,7 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
28062806
) g
28072807
ORDER BY g.ConnectionCount DESC, g.ConnectionGroup
28082808
FOR XML PATH(''), TYPE
2809-
).value('text()[1]', 'nvarchar(max)'), 1, LEN(@LineFeed), N'');
2809+
).value(N'.[1]', N'NVARCHAR(MAX)'), 1, LEN(@LineFeed), N'');
28102810

28112811
INSERT INTO #BlitzFirstResults (CheckID, Priority, FindingsGroup, Finding, URL, Details)
28122812
VALUES (
@@ -2818,9 +2818,9 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
28182818
'There are ' + CAST(@TotalConnections AS VARCHAR(20)) + ' open connections, which would lead to ' + @LineFeed
28192819
+ 'worker thread exhaustion and THREADPOOL waits' + @LineFeed
28202820
+ 'if they all ran queries at the same time.'
2821-
+ @LineFeed + @LineFeed + 'Top 5 Servers:' + ISNULL(@TopServers, @LineFeed + '(none)')
2822-
+ @LineFeed + @LineFeed + 'Top 5 Logins:' + ISNULL(@TopLogins, @LineFeed + '(none)')
2823-
+ @LineFeed + @LineFeed + 'Top 5 Apps:' + ISNULL(@TopApps, @LineFeed + '(none)')
2821+
+ @LineFeed + @LineFeed + 'Top 5 Servers:' + @LineFeed + ISNULL(@TopServers, '(none)')
2822+
+ @LineFeed + @LineFeed + 'Top 5 Logins:' + @LineFeed + ISNULL(@TopLogins, '(none)')
2823+
+ @LineFeed + @LineFeed + 'Top 5 Apps:' + @LineFeed + ISNULL(@TopApps, '(none)')
28242824
);
28252825
END
28262826
END

0 commit comments

Comments
 (0)