第一种:使用identity函数增加临时表的方法 select id = identity ( int , 1 , 1 ), * into #tmp from table select * from #tmp drop table #tmp 在SQL2005中新增了ROW_NUMBER()函数,给我们带来了很多方便,使用方法如下: SELECT id,ROW_NUMBER() OVER ( order by id) as RowNumber FROM Table 有一个方便,as后的别名可以在语句后面作为条件单独使用.