当前位置: 代码迷 >> Sql Server >> update觸發器解决思路
  详细解决方案

update觸發器解决思路

热度:86   发布时间:2016-04-27 17:40:28.0
update觸發器
請問大家在做一個庫存管理中,出庫後庫存減少。如果要對出庫單進行修改,那麼庫存又怎麼增加和減少呢!!!!

------解决方案--------------------
---amount 数量
create trigger Stock_update on 出库表
for update
as
update Stockamount
set amount=amount+(i.amount-d.amount)
from inserted i join deleted d
where
i.i.物品ID-d.物品ID
and Stockamount.物品ID=i.物品ID
  相关解决方案