select id=identity(int),a,b into #a from aaa
select id=identity(int),e,f into #b from bbb
select a=isnull(a.a,''),b=isnull(a.b,''),e=isnull(b.e,''),f=isnull(b.f,'')
from #a a full join #b b on a.id=b.id
drop table #a,#b
select id=identity(int),e,f into #b from bbb
select a=isnull(a.a,''),b=isnull(a.b,''),e=isnull(b.e,''),f=isnull(b.f,'')
from #a a full join #b b on a.id=b.id
drop table #a,#b
解决方案 »
- 我安装的是Sql Server 2005的180天评估版,现在快要到期了,怎样继续使用啊!我的系统是windows XP SP2 !
- sql处理并发访问机制的时候,是否是通过使用锁来实现的?
- 关于exists子查询问题
- 一个select 语句的问题
- 在WIN2K下如何连SQL SERVER 7?
- 向大型表中UPdate資料的問題
- SQL SERVER 7.0的数据导出问题
- 急急急,在线等待!!!sql 7.0 中的问题??
- 怎么实现局域网用Windows认证登录数据库
- txt格式转换到SQL
- 请教:在T-SQL中使用什么语句可以将某个表的所有字段名列出?
- 高级问题:进程pageiolatch ,pagelatch_ex状态是如何产生及如何解决?
insert into #t2 select identity(int,1,1) as id,e,f from 表2select a,b,e,f from #t1 right join #t2 on #t1.id=#t2.id
c d g h
i j
from aaa,bbb
from aaa a,bbb b
create table aaa(a varchar(10),b varchar(10))
insert aaa select 'a','b'
union all select 'c','d'create table bbb(e varchar(10),f varchar(10))
insert bbb select 'e','f'
union all select 'g','h'
union all select 'i','j'
go--查询
select id=identity(int),a,b into #a from aaa
select id=identity(int),e,f into #b from bbb
select a=isnull(a.a,''),b=isnull(a.b,''),e=isnull(b.e,''),f=isnull(b.f,'')
from #a a full join #b b on a.id=b.id
drop table #a,#b
go--删除测试
drop table aaa,bbb/*--测试结果a b e f
---------- ---------- ---------- ----------
a b e f
c d g h
i j(所影响的行数为 3 行)
--*/
c d g h
i j
--示例代码:
declare @aaa table(a char(2),b char(2))
insert into @aaa
select 'c','d' union all
select 'cc','dd'declare @bbb table(e char(2),f char(2))
insert into @bbb
select 'g','h' union all
select 'i','j' union all
select 'gg','hh' union all
select 'ii','jj'select [id]=identity(int),a,b into #a from @aaa
select [id]=identity(int),e,f into #b from @bbb
select a=isnull(a.a,''),b=isnull(a.b,''),e=isnull(b.e,''),f=isnull(b.f,'')
from #a a full join #b b on a.id=b.iddrop table #a,#b--测试结果:
a b e f
---- ---- ---- ----
c d g h
cc dd i j
gg hh
ii jj(所影响的行数为 4 行)