求一简单的SQL语句 一个表A,主键为 a,b从表B导入数据到A,B表结构和A相同,只是没有主键导入时就是提示主键重复。如何找出B表,a,b两字段相同的数据列来??? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 insert into a(a,b)select a,b from b bbwhere not exists(select 1 from a where bb.a=a and bb.b=b) select a,b,count(1) from bgroup by a,bhaving count(1)>1 select * from B where exists(select 1 from A where A.a=B.a and A.b=B.b) select * from Binner join(select a,b,count(1) from b group by a,b having count(1)=1) ton B.a=t.a and B.b=t.b select b.a,b.b from Bwhere exists (select * from A where A.a=B.a and A.b=B.b) select * from A_DB where Id in(select Id from B_DB)应该可以把 sqlserver连接不上 sql将普通列变为标识列 两个表都有一个 text 类型字段 如何对比找到 text 内数据不同的行? 求一条SQL语句 如何从出生年月中统计出年龄,并计算出占总数的百分比? 有关MSSQL2005 xml字段的空白节点问题,请大家帮忙 50分求一个简单的存储过程(急!!) 求SQL语句 我的sql server怎么导不出ACCESS文件 请问:在一个SQL Server的触发器中有没有可能调用一个外部程序? 创建表(存在),然后插入数据(则不存在表);乱码 关于mssql批量修改的问题!
insert into a(a,b)
select a,b from b bb
where not exists(select 1 from a where bb.a=a and bb.b=b)
select a,b,count(1) from b
group by a,b
having count(1)>1
inner join
(
select a,b,count(1) from b
group by a,b
having count(1)=1
) t
on B.a=t.a and B.b=t.b
where exists
(select * from A where A.a=B.a and A.b=B.b)