From d1373dc91903ce2f6e8646418959a75cc326cfbf Mon Sep 17 00:00:00 2001 From: Foundatum <118854223+Foundatum@users.noreply.github.com> Date: Tue, 22 Nov 2022 14:34:33 -0700 Subject: [PATCH] Fix Exponential growth in Daily simulation Repeated calls to this procedure cause exponential growth in orders. Including this condition fixes that. During the data simulation process, there is a process to pick orders. If there is not enough stock to pick a full order, that order is split into an Original and Backordered Order. This could result in a chain of orders, with only the final one having a null value for the BackorderOrderID. --- .../Stored Procedures/DailyProcessToCreateHistory.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/databases/wide-world-importers/wwi-ssdt/wwi-ssdt/DataLoadSimulation/Stored Procedures/DailyProcessToCreateHistory.sql b/samples/databases/wide-world-importers/wwi-ssdt/wwi-ssdt/DataLoadSimulation/Stored Procedures/DailyProcessToCreateHistory.sql index 6032ea37..51b0465b 100644 --- a/samples/databases/wide-world-importers/wwi-ssdt/wwi-ssdt/DataLoadSimulation/Stored Procedures/DailyProcessToCreateHistory.sql +++ b/samples/databases/wide-world-importers/wwi-ssdt/wwi-ssdt/DataLoadSimulation/Stored Procedures/DailyProcessToCreateHistory.sql @@ -39,6 +39,7 @@ BEGIN FROM (SELECT COUNT(*) AS OrderCount FROM Sales.Orders WHERE DATEPART(year,OrderDate) = DATEPART(year,(SELECT MAX(OrderDate) FROM Sales.Orders)) AND DATEPART(weekday,OrderDate) NOT IN (1,7) + AND BackorderOrderID IS NULL GROUP BY OrderDate) t END ELSE @@ -451,4 +452,4 @@ BEGIN THROW; END CATCH -END; \ No newline at end of file +END;