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

解决方案 »

  1.   

    select (select count(1) from vip where userid<=t.userid) as ID
           ,userid
           ,name
    from vip t
    order by userid
      

  2.   

    select identity(int,1,1) as id,* into # from VIP order by useridselect * from #这样做的话,我排一下序就乱掉了
      

  3.   

    二楼的大部分情况下都可以,不过当计算列有重复值就不行了,例如这里如果有相同的userid就不行,所以说计算列的值必须唯一