CREATE VIEW v_test
AS
  SELECT rid=ROW_NUMVER() OVER(ORDER BY id),*
  FROM tb;
GOSELECT * FROM v_test;

解决方案 »

  1.   

    create view  v_view
    as
    select id = row_number() over (order by col),* from ta
    go
      

  2.   

    create view  v_view 
    as 
    select id = (select count(1) from ta where 主键 < a.主键),* from ta  a
    go 
      

  3.   


       用 id int identity(1,1) 为id列
      

  4.   

    我用的sql2k,不支持row_number()
      

  5.   


    create view  v_view 
    as 
    select id = (select count(1) from ta where 主键 < a.主键),* from ta  a 
    go 
      

  6.   


    我的v_view是多表连接得到的,按你的方法查出来id有重复的