select id=identity(int,1,1),* into #temp from tablename
select * from #temp
drop table @temp

解决方案 »

  1.   

    用临时表了
    select IDENTITY(int,1,1) ID,d_rsgl.xm,d_kqgl.cd,d_gzgl.gz into #temp1 
    from d_rsgl,d_kqgl,d_gzglselect * from #temp1
      

  2.   

    用临时表了
    select IDENTITY(int,1,1) ID,d_rsgl.xm,d_kqgl.cd,d_gzgl.gz into #temp
    from d_rsgl,d_kqgl,d_gzglselect * from #temp
      

  3.   

    你在DATASET里定义一个计算字段RecNO
    然后在计算事件里写
    AdoDataSet1.FieldByName('RecNo').AsInteger := AdoDataSet1.RecNO;
      

  4.   

    如果你有主键的话select (select sum(1) from tablename where pkey<=a.pkey) as id,* from tablename a