就一个SQL查询: select * from db2 not exists(selec 1 from db1 where db1.field1=db2.field1 and db1.field2=db2.field2...)//条件字段根据你的实际情况 如果结果集不为空,就表示db2中有数据与db1不同。
select * from db2 where not exists (select 1 from db1 where db1.field1=db2.field1 and db1.field2=db2.field2...)条件字段可以自己加
if exists(select * from db2 where id not in (select id from db1)) print 'db2有数据db1中没有'
select * from db2 not exists(selec 1 from db1 where db1.field1=db2.field1
and db1.field2=db2.field2...)//条件字段根据你的实际情况
如果结果集不为空,就表示db2中有数据与db1不同。
(select 1 from db1 where db1.field1=db2.field1 and db1.field2=db2.field2...)条件字段可以自己加
(select id from db1))
print 'db2有数据db1中没有'