易截截图软件、单文件、免安装、纯绿色、仅160KB

sql server2000 数据比较 - MS-SQL Server / 应用实例

好:
 问一个问题,现在有两个数据库A,B,A中有一个c表,B中有一个d表,且这两个表的结构是一样的,现在c表有1200多万记录,d表也有1200多万记录,现在想把这两个表中不同的记录查出来,插到另一个表中,请教大家怎么办,数据很大,不知道怎么办,谢谢了
不同是怎么区分的?

给个示例?

按表中指定的某几个字段值进行区分

select a.* from a where a.id not in (select id from b)

insert into des_table 
select * from database1.dbo.table1 a where not exsits (select 1 from database2.dbo.table2 where col1= a.col1 and col2=a.col2 and...)
union all 
select * from database2.dbo.table2 b where not exsits (select 1 from database1.dbo.table1 where col1= b.col1 and col2=b.col2 and...)

引用
insert into des_table
select * from database1.dbo.table1 a where not exsits (select 1 from database2.dbo.table2 where col1= a.col1 and col2=a.col2 and...)
union all
select * from database2.dbo.table2 b where not exsits (select 1 from database1.dbo.table1 where col1= b.col1 and col2=b.col2 and...)

up…

三楼,效率如何啊,我这可是1000多万数据啊

全1000多万要什么效率? 等结果出来就好了,难到你经常用这个?


7楼你没有明白我的意思,我不是说经常用,我就是用一次,如果结果出来要很长时间,比如几天什么的,那肯定很麻烦了啊,呵呵


相关问答:

csv文件转换成sql导入到数据库,没有数据为何?

执行的顺序:
1)文件浏览框(选择文件使用)
选择好文件后
点击一个导入按钮的时候 ,把上面上传框里的csv文件以一个ID为文件名,上传到**/**文件夹下
2)读取这个文件夹下的csv的文件,转换成sql
3 ......

求一SQL - MS-SQL Server / 基础类

tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......

求一时间比较的SQL 指令 - MS-SQL Server / 基础类

表数据
COL1 COL2 COL2 COL4 COL5
----------------------------------------------------------------------------------------------
2010-05-05 00:00 ......

关于SQL语句OR的问题 - Oracle / 高级技术

通过NAME字段条件查询一个数据表,假设我有100个姓名,有以下两个方法,
方法1:
把100个Name 组成一个SQL语句,比如 Select * from tmp_table where Name='张三' or Name ='李四' Or ...Or Name='第一百个姓名'
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号