SQLserver触发器语句问题。

源表:源表
typeid    条码
0001    199999
0002    288888
0003    344444


被插入表内容为:
typeid    nunit   unitname       条码
0001          1       个              199999
0001          2       箱
0001          3
0002          1       个             288888
0002          2       箱
0002          3
0003          1       个             344444
0003          2       箱
0003          3

如何根据源表的typeid和条码批量被插入表内容呢?

twshe 发布于 2021-1-12 13:47 (编辑于 2021-1-12 13:48)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共1回答
最佳回答
0
twsheLv6初级互助
发布于2021-1-12 16:51

insert into T_Jxc_PtypeUnit(Ptypeid,nunit,unitname,BarCode) select 临时表.typeid,临时表.nunit,临时表.unitname,临时表.BarCode 

from 

(select typeid,1 as nunit,'个' as unitname,BarCode from ptype where Name like '%正牛%'

union

select typeid,2 as nunit,'箱' as unitname,'' BarCode from ptype where Name like '%正牛%'

union

select typeid,3 as nunit,'' as unitname,'' BarCode from ptype where Name like '%正牛%') as 临时表


  • 0关注人数
  • 338浏览人数
  • 最后回答于:2021-1-12 16:51
    请选择关闭问题的原因
    确定 取消
    返回顶部