Skip to content

Commit

Permalink
Fix for ServerTopQueries on SQL 2016
Browse files Browse the repository at this point in the history
Fixes a bug caused due to the metrics defaulting to NULL rather than 0, causing an error when using SUM() on them
  • Loading branch information
SQLozano committed Dec 14, 2023
1 parent 6a4a7f1 commit 4de5008
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ServerTopQueries/5-dbo.ServerTopQueries.Procedure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4de5008

Please sign in to comment.