select identity(int,1,1) newid,DD into #temp from table
select * from #temp
drop table #temp

解决方案 »

  1.   

    or:alter table table1 add newid int identity(1,1)
    select * from table1
    alter table table1 drop column newid
      

  2.   

    select identity(int,1,1) newid,DD into #temp from table
    select * from #temp
      

  3.   

    不对啊,我要用SELECT 语句!!!!并且不要建表(INTO)!!谢谢好手。可以吗??
      

  4.   

    没有办法除非你有主键列:select (select sum(1) from 表 where 主键<aa.主键) 编号,* from 表 aa
      

  5.   

    select (select sum(1) from 表 where 主键<aa.主键) 编号,* from 表 aa大力的方法可行,不过要看你的数据量的,还有表必须有唯一性索引
      

  6.   

    其实真的需要的话,就alter table加一个identity属性列好了