1:
Select *,identity(int,1,1) as id into #tmp from 表
Select * from #tmp2:
Select *,(Select sum(1) from 表 where 学号<= a.学号) as id 
from 表 a

解决方案 »

  1.   

    select 学号,姓名,(select count(*) from 学生学籍表 where 学号<=tem.学号) id from 学生学籍表 tem
      

  2.   

    select 学号,姓名,(select count(*) from 学生学籍表 a where a.学号<=b.学号) as id
     from 学生学籍表 b
      

  3.   

    或:select 学号,姓名,(select sum(1) from 学生学籍表 where 学号<=tem.学号) id from 学生学籍表 tem或:select 学号,姓名,IDENTITY(int, 1,1) id into #temp from 表
    select * from #tempdrop table #temp
      

  4.   

    这样呀:select 学号,姓名,IDENTITY(int, 1,1) id into #temp from 表select * from #tempdrop table #temp
      

  5.   

    我希望用一个select语句实现,因为这往往是前端程序所需要的呀!csdn现在怎么其慢无比!!!
      

  6.   

    没有顺序列,不用临时表,用一句话,sqlserver可能不行,其实你在你的表里加一个标识列不就得了。