日期:2014-05-18  浏览次数:20469 次

请问sql2000,在视图里如何加一列自增列?
rt

------解决方案--------------------
SQL code
select id=identity(int,1,1) ,* into #t from tb

------解决方案--------------------
探讨
SQL code
select id=identity(int,1,1) ,* into #t from tb

------解决方案--------------------
--sql 2000

select t.* , px = (select count(1) from tb where col < t.col) + 1 from tb t

--sql 2005

select t.* , px = row_number() over(order by col) from tb t
------解决方案--------------------
探讨
是在视图里,视图上不能这样用