1.将数据将Excel 文件中的数据导入到一张临时的数据库表中
2.将临时表中的数据导入到目标表中,并判有相同数据库插入
–目标表
create table order_detail(
od_id nvarchar(50) primary key NOT NULL,
od_price float NOT NULL
od_outtime datetime NULL
)
— 临时表
create table temp(
od_id nvarchar(50) primary key NOT NULL,
od_price float NOT NULL
od_outtime datetime NULL
)
select * from temp
select * from order_detail
insert into 目标表(字段1,字段2,字段3)
select 字段1,字段2,字段3 from 临时表 where 不能重复的字段 not in (select 不能重复的字段 from 目标表 )
insert into order_detail(od_id,od_price,od_outtime)
select od_id,od_price,od_outtime from temp where od_id not in (select od_id from order_detail )