select IDENTITY(int,1,1) AS new_id ,* into #temp form a where a1>10
select * from #temp

解决方案 »

  1.   

    select IDENTITY(int,1,1) new_id ,* into #temp from a where a1>10
    select * from #temp
      

  2.   

    --SQL中只能在生成表的查询语句中使用,不能直接在查询中使用indentity--改为:
    select new_id=identity(int,1,1),*  into #t from a where a1>10
    select * from #t  --显示结果
    drop table #t     --完成后删除临时表
      

  3.   

    select new_id=identity(int,1,1),*  into #t from a where a1>10
    select * from #t  --显示结果
    drop table #t
      

  4.   

    如存在象id这样的唯一列,你可以:select (select sum(1) from a where id<=tem.id and a1>10) new_id,* from a tem where a1>10 order by idorselect (select count(*) from a where id<=tem.id and a1>10) new_id,* from a tem where a1>10 order by id