2000及2005通用分页
2000及2005通用分页。
1:3次排序分页。
select * from (
select top 10 * from
(
select top 20 * from
SourceTable order by [id] asc
) as TempTable order by [id] desc
) as RetTable order by [id] asc
2:双TOP分页。
select top 10 * from SourceTable
where [Id] not in
(
select top 10 [Id] from SourceTable
)
3:MAX分页。
select top 10 * from SourctTable
where [Id] > (
select max([Id])from (select top 20 [Id] from SourctTable order by [Id]) as TempTable
)
2005新函数分页:
1:row_number分页。
select * from (
select row_number()over(order by [Id]) as RowIndex , * from SourceTable
) as TempTable where RowIndex between 10 and 100
本人将一张空表里面先插入了40多万条数据,使用三次排序和MAX进行了分页测试:
每页100条数据结果:
三次排序分页使用时间:
MAX分页使用时间:
再插入60万条数据,再次测试结果如下:
每页100条数据结果:
三次排序分页使用时间:
MAX分页使用时间: