当前位置: 代码迷 >> Sql Server >> 请教sql2000,在视图里怎么加一列自增列
  详细解决方案

请教sql2000,在视图里怎么加一列自增列

热度:39   发布时间:2016-04-27 12:59:36.0
请问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
------解决方案--------------------
探讨
是在视图里,视图上不能这样用
  相关解决方案