存储过程实现分页

代码
create proc sp_pagingwithproc
@page int
as
declare @count int
set @count = (select count(0from testtable)
select top 5 b.*
from (
    
select top (@count - 5*@page) indexcloumn
    
from testtable
    
order by indexcloumn desc) a,testtable b
where b.indexcloumn = a.indexcloumn
order by a.indexcloumn

@page 页码,0开始

@count 该表一共存在的纪录数

@testtable 表名

@indexcloumn 排序列

posted @ 2010-02-20 21:01  郭鹏  阅读(234)  评论(0编辑  收藏  举报