读书人

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

发布时间: 2012-05-08 22:09:41 作者: rapoo

请问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
[解决办法]
探讨
是在视图里,视图上不能这样用

读书人网 >SQL Server

热点推荐