您的位置:首页 > 数据库

SQL 分页查询 存储过程

2011-01-19 22:23 239 查看
QSL--Server2008

创建分页查询的存储过程

if exists(select * fron sysobjects where name='Proc_pages')

drop proc proc_pages

go

create proc proc_ages

@oneCounts int, --每页条数

@wantPages int --想要到的页数

as

declare @sum int

set @sum = (@wantPages-1)*@oneCounts

select top(@oneCounts)* from MessagesInfo where MId not in (select top(@sum) MID from MessageInfo)

go

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