数据整合中用到的一些sql,老鸟别看了,欢迎大家扔砖。
1、表备份 (创建表,并插入新数据)
select * into table_bak from table_old
2、批量插入新数据(不创建表,直接将新数据插入表)
insert into foodlic_info_redy (chr_id
,flicseq
,fbiseq
,fspno
,flicmno
,flicdno
,fhiino
,fliccode,flicitemnm,forgno)
select chr_id
,isnull(flicseq,999999) as flicseq
,isnull(fbiseq,999999) as fbiseq
,isnull(fspno,999999) as fspno
,isnull(flicmno,999999) as flicmno
,isnull(flicdno,999999) as flicdno
,isnull(fhiino,999999) as fhiino
,fliccode,flicitemnm,forgno
from ib_tbs_orglicm_191
where not exists (select 1 from foodlic_info_redy
where foodlic_info_redy.chr_id=ib_tbs_orglicm_191.chr_id);