读书人

update器解决思路

发布时间: 2012-01-28 22:06:13 作者: rapoo

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

读书人网 >SQL Server

热点推荐