同一数据库内两个表进行数据导入 表A有字段 id(identity1,1) 序列号 数量 种类 等表B有字段 id(identity1,1) 序列号 型号 数量 种类 来源 等表A中的数据有一部分在表B中也有,还有一部分表B中没有需要从表A中导过来(主要导的是序列号,数量,种类,型号默认为1)求语句 或者小程序 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 insert 表B ( 序列号 ,数量 ,种类, 型号) select 序列号, 数量, 种类,1 from 表A where not exists(select 1 from 表B where 表B.序列号= 表A.序列号 and 表B.种类=表A.种类) insert into B select identity1, qty, type, 1 from A except select identity1, qty, type, 1 from B insert into B (序列号,数量 ,种类,型号)select A.序列号,A.数量,A.种类,1 as[型号] from Awhere not exists (select 1 from B where A.序列号=B.序列号) 数据库问题请教? SQL排序问题。。。 麻烦帮我看一下错误 SQL排序 遇到一个困难查询的问题 关于老师和课程信息的数据表的设计,头大 连接语句中*号的作用 这个 SQL 语句怎么写? SELECT COUNT(*) FROM CONTAINSTABLE(Docs, *,'关键字')语句出错? 请问sqlsever是不是免费软件?http://www.microsoft.com/china/sql/downloads/2000/CHSsp1.asp 这里的是不是? 行转列 求教高手 求一数据库语句,在线等
insert 表B ( 序列号 ,数量 ,种类, 型号)
select 序列号, 数量, 种类,1 from 表A
where not exists(select 1 from 表B where 表B.序列号= 表A.序列号 and 表B.种类=表A.种类)
except
select identity1, qty, type, 1 from B
insert into B (序列号,数量 ,种类,型号)
select A.序列号,A.数量,A.种类,1 as[型号] from A
where not exists (select 1 from B where A.序列号=B.序列号)