读书人

sqlserver 批量增添和修改语句用select

发布时间: 2012-08-07 14:54:48 作者: rapoo

sqlserver 批量添加和修改语句用select

修改语句:

beginupdate PRODUCE_TASKSDETAIL set gcount=a.gcount+                           case c.STANDBATCH                            when '0' then @unitCount*b.STANDBATCH                            else @unitCount/c.STANDBATCH*b.STANDBATCH                           end            from PRODUCE_TASKSDETAIL as a,PRODUCE_BOM_SUB as b,PRODUCE_BOM_BOM as c            where a.goodsid=b.goodsid and b.BOMID=c.BOMID and c.GOODSID=@goodsId and a.tasksid=@tasksId         end

?添加语句:

begin    insert into PRODUCE_TASKSDETAIL(SALEORDER_BILLCODE,TASKSID,GOODSID,UNITID,goodsCount,GCOUNT,GPRICE)                   select @billCode,@tasksId,a.GOODSID,a.UNITID,a.STANDBATCH,                           case c.STANDBATCH                            when '0' then @unitCount*a.STANDBATCH                            else @unitCount/c.STANDBATCH*a.STANDBATCH                           end                          ,b.APRICE from PRODUCE_BOM_SUB as a,BASE_GOODS as b,PRODUCE_BOM_BOM as c                   where a.GOODSID=b.GOODSID and a.BOMID=c.BOMID and a.BOMID in(select BOMID from PRODUCE_BOM_BOM where GOODSID=@goodsId) end
?

读书人网 >SQL Server

热点推荐