--数据如下
create table #a([A] int,[B] int)
go
insert into #a 
SELECT 1,2 UNION
SELECT 2,6 UNION
SELECT 3,5 UNION
SELECT 4,3 UNION
SELECT 5,4select * from #a
select * from #a order by A descdrop table #a--如何得到下表 (就是把第二个表里的内容,直接拼到第一个表的后面。)
A B A2 B2
------------------------------
1 2 5 4
2 6 4 3
3 5 3 5
4 3 2 6
5 4 1 2

解决方案 »

  1.   

    create table #a([A] int,[B] int)
    go
    insert into #a 
    SELECT 1,2 UNION
    SELECT 2,6 UNION
    SELECT 3,5 UNION
    SELECT 4,3 UNION
    SELECT 5,4select *,id=identity(int,1,1) into # from #aselect *,id=identity(int,1,1) into #t from #a order by A descselect a.a,a.b,b.a as a2,b.b as b2
    from # as a full join #t as b on a.id=b.iddrop table #a
    drop table #
    drop table #t
    /*
    a           b           a2          b2          
    ----------- ----------- ----------- ----------- 
    1           2           5           4
    2           6           4           3
    3           5           3           5
    4           3           2           6
    5           4           1           2
    */
      

  2.   

    [sql]
    select * from #a
    Union all
    select * from #a order by A desc
    [\sql]
    可以放下面,放后面就不知道了,或许需要建一个空表吧,类型要匹配