Skip to content

Commit 986298a

Browse files
committed
Updating StockItem history
Added post-deployment script that updates StockItem history table with lineary increasing prices and lineary decreasing taxes and lead times.
1 parent c27f06a commit 986298a

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

samples/databases/wide-world-importers/wwi-ssdt/wwi-ssdt/PostDeploymentScripts/Script.PostDeployment1.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ EXEC DataLoadSimulation.DailyProcessToCreateHistory
172172
GO
173173

174174
:r .\pds400-ins-unkown-orderline.sql
175+
:r .\pds410-update-archive-tables.sql
175176

176177
/*
177178
There is one other stored procedure you may find useful:
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
-- NOTE: This script should be moved to MakeTemporalChanges procedure, but currently it doesn't work there.
2+
-- jovanpop creating a separate file here.
3+
-- @TODO: Investigate how to move it there.
4+
5+
PRINT N'Updating StockItems history...'
6+
GO
7+
EXEC DataloadSimulation.DeactivatetemporalTablesBeforeDataLoad;
8+
GO
9+
UPDATE Warehouse.StockItems_Archive
10+
SET UnitPrice = s.UnitPrice * (1 - .05 *(DATEDIFF(DAY, sa.ValidFrom, GETDATE())/365 )),
11+
RecommendedRetailPrice = s.RecommendedRetailPrice * (1 - .03 *(DATEDIFF(DAY, sa.ValidFrom, GETDATE())/365 )),
12+
TaxRate = s.TaxRate * (1 + .02 *(DATEDIFF(DAY, sa.ValidFrom, GETDATE())/365 )),
13+
QuantityPerOuter = CEILING(s.QuantityPerOuter * (1 + .05 *(DATEDIFF(DAY, sa.ValidFrom, GETDATE())/365 ))),
14+
LeadTimeDays = CEILING(s.LeadTimeDays * (1 + .03 *(DATEDIFF(DAY, sa.ValidFrom, GETDATE())/365 ))),
15+
TypicalWeightPerUnit = CEILING(s.TypicalWeightPerUnit * (1 + .02 *(DATEDIFF(DAY, sa.ValidFrom, GETDATE())/365 )))
16+
FROM Warehouse.StockItems_Archive sa
17+
JOIN Warehouse.StockItems s
18+
ON sa.StockItemID = s.StockItemID;
19+
GO
20+
EXEC DataloadSimulation.ReActivatetemporalTablesAfterDataLoad;
21+
GO

samples/databases/wide-world-importers/wwi-ssdt/wwi-ssdt/WideWorldImporters.sqlproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,5 +844,6 @@
844844
<None Include="PostDeploymentScripts\pds105-ins-dls-ficticiousnamepool.sql" />
845845
<None Include="PostDeploymentScripts\pds106-ins-dls-areacode.sql" />
846846
<None Include="PostDeploymentScripts\pds400-ins-unkown-orderline.sql" />
847+
<None Include="PostDeploymentScripts\pds410-update-archive-tables.sql" />
847848
</ItemGroup>
848849
</Project>

0 commit comments

Comments
 (0)