除数为0如何判断 有个触发器在更新表的时候执行update 原料 set 单价=总价/库存数现在我发现当遇到库存数减为0了会出错,应该如何修改触发器令库存数为0时单价也为0就可以。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 update 原料 set 单价=总价/nullif(库存数,0) --或者update 原料 set 单价=case when 库存数=0 then 0 else 总价/库存数 end update 原料 set 单价=case when 库存数=0 then 0 else 总价/库存数 end update 原料 set 单价=case when 库存数<>0 then 总价/库存数 else 0 end update 原料 set 单价=case when 库存数=0 then 0 else 总价/库存数 end update 原料 set 单价=case 库存数 when 0 then 0 else 总价/库存数 end update 原料 set 单价=(case when isnull(库存数,0)=0 then 0 else 总价/库存数 end) update 原料 set 单价=总价/nullif(库存数,0) SQL 指定语句 如何导出txt ------一定给分的 按分钟分组的SQL应该怎么写 dba面试题 数据库进行分区表问题 求一条SQL分类计算语句 如何实现排序且进行分类汇总 sql 关于数据是否修改过的问题!~ 如何转移sqlserver中一个数据库的“关系”,复制到另一个数据库中去??? 触发器问题 关于MS -SQL 2005 Datebase table index 问题请教 sql2000,返回随机记录 用union all会打乱记录顺序 有解决方法吗?
update 原料 set 单价=总价/nullif(库存数,0)
--或者
update 原料 set 单价=case when 库存数=0 then 0 else 总价/库存数 end
update 原料
set 单价=case when 库存数<>0 then 总价/库存数 else 0 end