Skip to content

Commit 195437b

Browse files
author
Darling Data
committed
Automation: Format and Build SQL File [skip ci]
1 parent c996931 commit 195437b

1 file changed

Lines changed: 33 additions & 7 deletions

File tree

Install-All/DarlingData.sql

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- Compile Date: 03/23/2026 17:38:09 UTC
1+
-- Compile Date: 03/23/2026 19:02:42 UTC
22
SET ANSI_NULLS ON;
33
SET ANSI_PADDING ON;
44
SET ANSI_WARNINGS ON;
@@ -36737,7 +36737,7 @@ BEGIN
3673736737
SELECT 'object_name: the stored procedure, function, or trigger this query belongs to, or "Adhoc" for ad hoc SQL' UNION ALL
3673836738
SELECT 'query_sql_text: representative query text (the most-executed variant for this query_hash)' UNION ALL
3673936739
SELECT 'query_plan: the most recent execution plan (XML) for this query_hash' UNION ALL
36740-
SELECT 'top_waits: top 3 Query Store wait categories with total wait time in ms (SQL 2017+ only, NULL on 2016)' UNION ALL
36740+
SELECT 'top_waits: top 3 Query Store wait categories with total wait time in ms (SQL 2017+ with wait stats enabled, omitted otherwise)' UNION ALL
3674136741
SELECT 'query_hash: the query_hash that groups all parameterized variants of the same query' UNION ALL
3674236742
SELECT 'query_count: how many distinct query_ids share this hash (parameterized variants)' UNION ALL
3674336743
SELECT 'plan_count: how many distinct plans exist across all variants. >1 may indicate plan instability.' UNION ALL
@@ -41494,11 +41494,31 @@ SELECT
4149441494
END + N',
4149541495
pw.primary_window,
4149641496
qi.object_name,
41497-
rt.query_sql_text,
41497+
query_sql_text =
41498+
(
41499+
SELECT
41500+
[processing-instruction(query)] =
41501+
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
41502+
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
41503+
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
41504+
rt.query_sql_text COLLATE Latin1_General_BIN2,
41505+
NCHAR(31),N''?''),NCHAR(30),N''?''),NCHAR(29),N''?''),NCHAR(28),N''?''),NCHAR(27),N''?''),NCHAR(26),N''?''),NCHAR(25),N''?''),NCHAR(24),N''?''),NCHAR(23),N''?''),NCHAR(22),N''?''),
41506+
NCHAR(21),N''?''),NCHAR(20),N''?''),NCHAR(19),N''?''),NCHAR(18),N''?''),NCHAR(17),N''?''),NCHAR(16),N''?''),NCHAR(15),N''?''),NCHAR(14),N''?''),NCHAR(12),N''?''),
41507+
NCHAR(11),N''?''),NCHAR(8),N''?''),NCHAR(7),N''?''),NCHAR(6),N''?''),NCHAR(5),N''?''),NCHAR(4),N''?''),NCHAR(3),N''?''),NCHAR(2),N''?''),NCHAR(1),N''?''),NCHAR(0),N'''')
41508+
FOR XML
41509+
PATH(N''''),
41510+
TYPE
41511+
),
4149841512
query_plan =
4149941513
TRY_CONVERT(xml, qp.query_plan),
41500-
qw.top_waits,
41501-
s.query_hash,
41514+
' +
41515+
CASE
41516+
WHEN @new = 1
41517+
AND @query_store_waits_enabled = 1
41518+
THEN N'qw.top_waits,
41519+
'
41520+
ELSE N''
41521+
END + N's.query_hash,
4150241522
s.query_count,
4150341523
s.plan_count,
4150441524
qi.query_id_list,
@@ -41832,9 +41852,15 @@ LEFT JOIN #hi_query_identifiers AS qi
4183241852
ON s.query_hash = qi.query_hash
4183341853
LEFT JOIN #hi_primary_window AS pw
4183441854
ON s.query_hash = pw.query_hash
41835-
LEFT JOIN #hi_query_waits AS qw
41855+
' +
41856+
CASE
41857+
WHEN @new = 1
41858+
AND @query_store_waits_enabled = 1
41859+
THEN N'LEFT JOIN #hi_query_waits AS qw
4183641860
ON s.query_hash = qw.query_hash
41837-
OUTER APPLY
41861+
'
41862+
ELSE N''
41863+
END + N'OUTER APPLY
4183841864
(
4183941865
SELECT TOP (1)
4184041866
qsp.query_plan

0 commit comments

Comments
 (0)