select id= identity(int,1,1),id,name  into  #hhh from student
select * from #hhh
drop table #hhh

解决方案 »

  1.   

    select idd= identity(int,1,1),id,name  into  #hhh from student
    select * from #hhh
    drop table #hhh
      

  2.   

    --如果你的表中有主键(或不重复的字段),可以这样做:select 序号=(select sum(1) from 表 where 主键<=a.主键),*
    from 表 a
    order by 主键
      

  3.   

    select rid= identity(int,1,1),id,name  into  #tmp from student
    select * from #tmp order by rid
    drop table #tmp
      

  4.   

    select identity(int,1,1) as seq,id,name into #tab1 from student
    select * from #tab1
    drop #tab1
    关于IDENTITY()函数的用法可以参考SQL联机帮助的内容。