我有表A,表B。我想从表A和B中查询出几条数据
放在新建的虚拟表C中,并给C起个标识列,请问我该怎么操作。
谢谢

解决方案 »

  1.   

    select *,id=identity(int,1,1) into #c from a
      

  2.   

    --如果A,B结构相同:
    select *,id=identity(int,1,1) into #c
    from 
    (select * from a 
    union all
    select * from b
    ) t
      

  3.   

    select id=identity(int,1,1),a.*,b.* into C from a join b on 条件
      

  4.   

    我A表和B表中有相同的数据,我想在C表中去掉一列,让相同的只显示一条,那该怎么办呢?
    用min ?
      

  5.   


    select id=identity(int,1,1),a.*,b.* into C from a join b on 条件a表跟B表有相同的列不要查出来就好了,,