您的位置:首页 > 数据库

数据库的分页练习

2012-11-12 21:05 141 查看
分页问题的练习

use 最终的练习

select * from MyStudents

select * from

(select *, ROW_NUMBER() over(order by FId) as rowIndex

from MyStudents)as tb1

where tb1.rowIndex between(5*2+1)and 5*3

create proc usp_MyStudents_GetDateByPageIndex

@pageSize int=10, --要有一个(表示的是这一页有多少条数据,给了其一个默认值,这个默认值为10,表示的就是一次查询能显示10条记录)这一页有多少条的pageSize的参数,设其默认值为10

@pageIndex int --表示的是第几页

as

begin

select * from

(select *, ROW_NUMBER() over(order by FId) as rowIndex

from MyStudents)as tb1

where tb1.rowIndex between(@pageSize*(@pageIndex-1)+1)and @pageSize*@pageIndex

end

exec usp_MyStudents_GetDateByPageIndex 5,3
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: