时间:2021-07-01 10:21:17 帮助过:33人阅读
declare @pageSize int --返回一夜的记录数 declare @CurPage int --页号(第几页) declare @Count int declare @id int set @pageSize=10 set @CurPage =1 --定位 if @CurPage = -1 begin --最后一页 set rowcount @pageSize select @id=newsID from newsT
declare @pageSize int --返回一夜的记录数
declare @CurPage int --页号(第几页)
declare @Count int
declare @id int
set @pageSize=10
set @CurPage =1
--定位
if @CurPage = -1
begin
--最后一页
set rowcount @pageSize
select @id=newsID from newsTemp order by newsID
end
if @CurPage > 0
begin
set @Count = @pageSize * (@CurPage -1) + 1
set rowcount @Count
select @id=newsID from newsTemp order by newsID desc
end
--返回记录
set rowcount @pageSize
select * from newsTemp where newsID <=@id order by newsID desc
set rowcount 0