sadier

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::
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
posted on 2004-08-28 15:32  毛小华  阅读(560)  评论(0)    收藏  举报