日期:2014-05-17 浏览次数:20595 次
create view test_view as select id=row_number over(order by getdate()),name from test where name like '%张%'
------解决方案--------------------
这就不需要建立视图了,用临时表。
select *,rid=identity(int,1,1)
into #tb
from tb
where name like '%张%'
select * from #tb
看看。
------解决方案--------------------
select row_number() over(order by id) as id ,name from test_view order by id
------解决方案--------------------
create view test_view as select ID=row_number()over(order by ID ), [name] from test where name like '%张%'
------解决方案--------------------
2楼是05写法,不过想问楼主为何要这样子去做。
------解决方案--------------------
你不是有自增列吗?id不按照1,2,3,4,5,6,7,8,9,10这样排序?
------解决方案--------------------
注意到2K
select (select count(*) from test_view where id <= a.id) as id ,name from test_view a order by id
------解决方案--------------------
难道是 select row_number() over(order by id) as id ,name from test_view order by id
------解决方案--------------------
... 2000的直接看7楼。
------解决方案--------------------
2楼的用临时表实现可以的,楼主试试