From 21b1bc2b9c138e5b88d9135c346455269d6f0394 Mon Sep 17 00:00:00 2001 From: Brandon Young Date: Wed, 18 Feb 2026 19:18:20 +0000 Subject: [PATCH] Update switching from LEAST() to CASE for NBRRecordsEligible --- .../Large Tables Data Cleanup/3B-RemoveOrphans.SQL | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Storage Management/Large Tables Data Cleanup/3B-RemoveOrphans.SQL b/Storage Management/Large Tables Data Cleanup/3B-RemoveOrphans.SQL index 78e3018d..19949451 100644 --- a/Storage Management/Large Tables Data Cleanup/3B-RemoveOrphans.SQL +++ b/Storage Management/Large Tables Data Cleanup/3B-RemoveOrphans.SQL @@ -243,7 +243,11 @@ BEGIN PRINT @SQL EXEC sp_executesql @SQL, N'@NBRecordsEligible BIGINT OUTPUT ', @nbRecordsEligible OUTPUT - SELECT @NBRecordsEligible = LEAST(@NBRecordsEligible, @BatchSize) ; + SELECT @NBRecordsEligible = + CASE WHEN @NBRecordsEligible < @BatchSize + THEN @NBRecordsEligible + ELSE @BatchSize + END; IF @maxRecId = 0 BEGIN