select identity(int,1,1)as id, name into #t1 from tab1
select * from #t1

解决方案 »

  1.   

    select (select count(*) from tablename where id<=a.id) as id,name
    from tablename a
      

  2.   

    我想知道一下,这个sql语句中的a是设么意思!
      

  3.   

    晕啊
    a 就是你的table的别名
      

  4.   

    支持版主,a 是別名,有時表名很長,或是一個意義不明確的名字,使用別名可以簡化或使其名字有一個的意義。
    如:
    第一種
    select * from SalesOfMonday mon,SalesOfTuesday tue where mon.id=tue.id
    第二種
    select * from table00001 Order,table00002 Custom where Order.cust_id=Cust.cust_id
      

  5.   

    hi,
    weixy
    you are good