UPDATE TBL_StockInventory
SET PeriodEndAmount = TBL_StockInventorytemp.CheckInventory
FROM TBL_StockInventorytemp
WHERE (TBL_StockInventory.BranchNo = 'isf') AND (InventoryID = 3) AND
TBL_StockInventory.materialno = TBL_StockInventorytemp.materialno AND
TBL_StockInventorytemp.BranchNo = 'isf'
把上期的期末变为本期的期初。
0.1建视图
SELECT MaterialNo, InventoryID, PeriodEndAmount, PeriodStartAmount, BranchNo
FROM dbo.TBL_StockInventory
WHERE (InventoryID = 2) AND (BranchNo = N'icm')
0.2处理
UPDATE TBL_StockInventory
SET periodstartamount = view1.periodendamount
FROM view1
WHERE (TBL_StockInventory.BranchNo = 'icm') AND
TBL_StockInventory.materialno = view1.materialno AND
TBL_StockInventory.inventoryid = 3
SET PeriodEndAmount = TBL_StockInventorytemp.CheckInventory
FROM TBL_StockInventorytemp
WHERE (TBL_StockInventory.BranchNo = 'isf') AND (InventoryID = 3) AND
TBL_StockInventory.materialno = TBL_StockInventorytemp.materialno AND
TBL_StockInventorytemp.BranchNo = 'isf'
把上期的期末变为本期的期初。
0.1建视图
SELECT MaterialNo, InventoryID, PeriodEndAmount, PeriodStartAmount, BranchNo
FROM dbo.TBL_StockInventory
WHERE (InventoryID = 2) AND (BranchNo = N'icm')
0.2处理
UPDATE TBL_StockInventory
SET periodstartamount = view1.periodendamount
FROM view1
WHERE (TBL_StockInventory.BranchNo = 'icm') AND
TBL_StockInventory.materialno = view1.materialno AND
TBL_StockInventory.inventoryid = 3

浙公网安备 33010602011771号