--用临时表
select id=identity(int,1,1),* into #t from table1
select * from #t

解决方案 »

  1.   

    SELECT IDENTITY(smallint, 1, 1) AS num,*
    INTO table1_temp
    FROM table1
      

  2.   

    ---写入临时表
    select IDNo=identity(int,1,1),* into #table from 表
    ---从临时表读数据
    select * from #table
      

  3.   

    如果a,b字段的组合不重复,而且按a,b排序select (select count(*) from table1 where a<x.a or (a=x.a and b<=x.b)) as num,* 
    from table1 x
    order by a,b
      

  4.   

    那谁知道delphi 的dataset,得到得结果集,能在每行前面手工加个序号?
      

  5.   

    如果有主键(key):
    select sn=(select sum(1) from tablename b where b.key<=a.key),* from tablename a
      

  6.   

    --没有主键的话,用临时表--有主键的话(值不重复的字段也可以算做主键),用:select 序号=(select count(*) from 表 where 主键<=a.主键),* from 表 a
    order by 主键  --因为序号是根据主键大小生成的,所以排序一下
      

  7.   

    用前台加序号就简单多了,你读数据集的时候正好要用到循环语句,付值一个变量,初始值为0
    i=0
    每读一个数据就让i+1
    并打印i
    这不就行了