with a (x) as
(select 101 union all
select x+1 from a where x<200
)
select ROW_NUMBER() over (order by x) as id,* from a
--在Server 2000 中能通过自定义函数生成一个排序列吗?
--用indetity要配合INTO 使用,
--Server 2000 不支持ROW_NUMBER(),我需要在查询语句中使用。
/*
id x
-------------------- -----------
1 101
2 102
3 103
4 104
5 105
6 106
....
*/
------解决思路----------------------
with a (x) as
(select 101 union all
select x+1 from a where x<200
)
select (select count(1) AS ID FROM a as b where a.x>=b.X) as id,x from a