select code,name,identity(int,1,1) as id into tmp from test where .. order by code
这样不行吗?

解决方案 »

  1.   

    select code,name,identity(int,1,1) as id  from test where .. order by code into tmp
      

  2.   

    select identity(int,1,1) as id,* into tmp from test where .. order by code
      

  3.   

    ???
    select identity(int,1,1),*
    from (select * from test where .. order by code)
      

  4.   

    to psxfghost: 谢谢你的回复.不行呀,结果:
    code   name       id
    --------------------------     
    BDJB   病毒警报 1
    YCYKX  越策越开心 2
    RXBS   人性本善 3
    MLSZ   美丽使者 4
      

  5.   

    select a.* into tmp from (select code,name,identity(int,1,1) as id from test where .. order by code) as a
    这样应该可以吧