select identity(int,1,1) FID,* into #temp from tablename where ...
select * from #temp 
drop table #temp

解决方案 »

  1.   

    就像
    行号     column1
    1         abc
    2
    3
    4
    5
    6
      

  2.   

    select *,identity(int,1,1) as id into #t from Tablename
    select * from #t
    drop table #t
      

  3.   

    to  sdhdy(大江东去...)
    服务器: 消息 8108,级别 16,状态 1,行 1
    无法使用 SELECT INTO 语句向表 '#temp' 中添加标识列,该表中已有继承了标识属性的列 'row_id'。
      

  4.   

    to  sdhdy(大江东去...)
    不好意思,我的语句写错误了
    你的语句写的可以
    能不能不用临时表???
      

  5.   

    select *,identity(int,1,1) as id into #t from Tablename
    select * from #t
      

  6.   

    to dlpseeyou(豆子)
    你要清掉临时表
      

  7.   

    有标识号就好办了select (select count(*) from Yourtab where 标识列<=A.标识列) as ORD,* from Yourtab A