我用的是sql2000,最好是能在一个select中加入,而不用生成一个临时表,有这种方法吗?

解决方案 »

  1.   

    需要使用临时表了.
    select identity(int,1,1),* into #t from table1
    select * from #t
      

  2.   

    select identity(int,1,1) as sn,* into #t from table1
    select * from #t
      

  3.   

    select identity(int,1,1) as sn,* into #t from table1
    select * from #t
    1f正解,需要先插入临时表里,然后再查询出来
      

  4.   

    to echiynn(寶玥) ,有的,有个id列,不重复,请问该怎么利用这个列呢?
      

  5.   

    select 序号=(select count(*) from 表 where id<=a.id),* from 表 a
      

  6.   

    yesyesye , 请问"序号=(select count(*) from 表 where id<=a.id)"中,表是什么表?我现在的表有序号,但是不连续,也不是从1开始。我现在想按id 倒序排列(从大到小),并且自动加序号,序号从1开始。