开心人生

用今天的努力----实现我所向往的明天

导航

merge 查询 示例

merge into nk2yangz_car d
using car s
on (d.id = s.id)
when matched then
  update
     set d.code    = s.code,
         d.organ   = s.organ,
         d.device  = s.device,
         d.cam_num = s.cam_num
   where d.id = s.id
when not matched then
  insert(d.id, d.code, d.organ) values (s.id, s.code, s.organ);

--查询2

--merge 插入
merge into nk2yangz_car d
using (select * from nk2suq_car where id = 65012) nk2suq_car s
on (nk2yangz_car.id = nk2suq_car.id)
when matched then
  update
     set nk2yangz_car.code    = nk2suq_car.code,
         nk2yangz_car.organ   = nk2suq_car.organ,
         nk2yangz_car.device  = nk2suq_car.device,
         nk2yangz_car.cam_num = nk2suq_car.cam_num
   where nk2yangz_car.id = nk2suq_car.id
when not matched then
  insert values (nk2suq_car.id, nk2suq_car.code, nk2suq_car.organ);

posted on 2008-10-30 17:58  hai  阅读(194)  评论(0)    收藏  举报