Skip to content

Commit d1373dc

Browse files
authored
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.
1 parent 862e493 commit d1373dc

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

samples/databases/wide-world-importers/wwi-ssdt/wwi-ssdt/DataLoadSimulation/Stored Procedures/DailyProcessToCreateHistory.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ BEGIN
3939
FROM (SELECT COUNT(*) AS OrderCount FROM Sales.Orders
4040
WHERE DATEPART(year,OrderDate) = DATEPART(year,(SELECT MAX(OrderDate) FROM Sales.Orders))
4141
AND DATEPART(weekday,OrderDate) NOT IN (1,7)
42+
AND BackorderOrderID IS NULL
4243
GROUP BY OrderDate) t
4344
END
4445
ELSE
@@ -451,4 +452,4 @@ BEGIN
451452
THROW;
452453
END CATCH
453454

454-
END;
455+
END;

0 commit comments

Comments
 (0)