易截截图软件、单文件、免安装、纯绿色、仅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楼你没有明白我的意思,我不是说经常用,我就是用一次,如果结果出来要很长时间,比如几天什么的,那肯定很麻烦了啊,呵呵


相关问答:

Asp+sql server问题 - Web 开发 / ASP

我一个项目,有个插入操作,具体是这样的:
我有进货信息表。在出货时选择相应的进货信息,输入数量,选择部门后,点保存按钮,由于网络延时,点一下没有反映,于是用户就又点一下,导致一次插入了两条记录:
例: ......

求一个SQL语句 - MS-SQL Server / 基础类

字段1,字段2.....字段N,Status,ParentID
1,Name1....test1,1,99
1,Name1....test1,3,99
1,Name2....test2,1,101
1,Name2....test2,3,101
1,Name3....test3,2,101
1,Name1....test1,4,101
想要的结果是:
1,Na ......

sql 问题 - MS-SQL Server / 基础类

需求如下:
学院 academy(aid,aname)
班级 class(cid,cname,aid)
学生 stu(sid,sname,aid,cid)
住宿区 region(rid,rname)
宿舍楼 build(bid,rid,bnote) bnote是‘男’/‘女’
宿舍 dorm(did,rid,bid,bedn ......

一条 SQL - Oracle / 基础和管理

有这样一条SQL
 Select Get_Costtaxrate(col1), Get_Tcostvalue(col1) from a
 
其中Get_Costtaxrate、Get_Tcostvalue都是函数,这两个函数里面都是查找一个大表,Get_Tcostvalue还需要调用Get_C ......

关于Sql的问题 - .NET技术 / ASP.NET

将一个查询语句赋给一个变量,如下:
DECLARE @STR NVARCHAR(MAX)
SET @STR='SELECT * from SALE_PROD'
怎么样才能执行它呢?
请高手,仁兄,侠姐帮帮忙啊


多谢,可以啦,高手啊

直接执行就行了

exec ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号