From 4de50081e733b677cdcaa9fee8243c0d52aaab3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Lozano=20Fern=C3=A1ndez?= Date: Thu, 14 Dec 2023 12:08:24 +0100 Subject: [PATCH] Fix for ServerTopQueries on SQL 2016 Fixes a bug caused due to the metrics defaulting to NULL rather than 0, causing an error when using SUM() on them --- ServerTopQueries/5-dbo.ServerTopQueries.Procedure.sql | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ServerTopQueries/5-dbo.ServerTopQueries.Procedure.sql b/ServerTopQueries/5-dbo.ServerTopQueries.Procedure.sql index 9d13f03..6c7bd5d 100644 --- a/ServerTopQueries/5-dbo.ServerTopQueries.Procedure.sql +++ b/ServerTopQueries/5-dbo.ServerTopQueries.Procedure.sql @@ -94,6 +94,10 @@ -- Date: 2022.10.18 -- Auth: Pablo Lozano (@sqlozano) -- Changes: Fixed bug ocurring when some metrics caused a divide by zero error with @Percentages = 1 +-- +-- Date: 2023.12.14 +-- Auth: Pablo Lozano (@sqlozano) +-- Changes: Fixed bug ocurring when running on SQL 2016 due to metrics defaulting to NULL rather than 0 ---------------------------------------------------------------------------------- CREATE OR ALTER PROCEDURE [dbo].[ServerTopQueries] @@ -359,7 +363,7 @@ FROM [st2] -- If the SQL version is 2016, exclude components not available on that version - START IF (@Version = 13) BEGIN - SET @SqlCommand2PopulateTempTableTemplate = REPLACE(@SqlCommand2PopulateTempTableTemplate, '{@SQL2016columns}', 'NULL --') + SET @SqlCommand2PopulateTempTableTemplate = REPLACE(@SqlCommand2PopulateTempTableTemplate, '{@SQL2016columns}', '0 --') END ELSE BEGIN