当前位置:StudyEZ>学易考试社区>IT>数据库>百万数据翻页就像100条数据一样!

百万数据翻页就像100条数据一样!

上一主题 下一主题
1页, 共1页 (共1楼)

百万数据翻页就像100条数据一样!

2007-08-15 5:53 下午

 

百万数据翻页就像100条数据一样!

if @CurPage=0
begin
--统计总记录数
select @allCount=count(ProductId) from Product_test

set @pageSize=10
--返回第一页的数据
select top 10
ProductId,
ProductName,
Introduction
from Product_test order by ProductId
end

 

else if @CurPage=-1

select * from
(select top 10 ProductId,
ProductName,
Introduction

from Product_test order by ProductId desc ) as aa
order by ProductId
else

begin
if @isNext=1
--翻到下一页
select top 10 ProductId,
ProductName,
Introduction
from Product_test where ProductId > @LastID order by ProductId


else
--翻到上一页
select * from
(select top 10 ProductId,
ProductName,
Introduction
from Product_test where ProductId < @FirstID order by ProductId desc) as bb order by ProductId
end

 

1页, 共1页 (共1帖)