sqlserver存储过程经典分页
2008-03-04 09:07
495 查看
CREATE procedure GetUsers
(@pagesize int,
@pageindex int,
@docount bit)
as
set nocount on
if(@docount=1)
select count(userId) from Users
else
begin
declare @indextable table(id int identity(1,1),nid int)
declare @PageLowerBound int
declare @PageUpperBound int
set @PageLowerBound=(@pageindex-1)*@pagesize
set @PageUpperBound=@PageLowerBound+@pagesize
set rowcount @PageUpperBound
insert into @indextable(nid) select userId from Users order by userName desc
select O.* from Users O,@indextable t where O.userId=t.nid
and t.id>@PageLowerBound and t.id<=@PageUpperBound order by t.id
end
set nocount off
GO
(@pagesize int,
@pageindex int,
@docount bit)
as
set nocount on
if(@docount=1)
select count(userId) from Users
else
begin
declare @indextable table(id int identity(1,1),nid int)
declare @PageLowerBound int
declare @PageUpperBound int
set @PageLowerBound=(@pageindex-1)*@pagesize
set @PageUpperBound=@PageLowerBound+@pagesize
set rowcount @PageUpperBound
insert into @indextable(nid) select userId from Users order by userName desc
select O.* from Users O,@indextable t where O.userId=t.nid
and t.id>@PageLowerBound and t.id<=@PageUpperBound order by t.id
end
set nocount off
GO
相关文章推荐
- 云数据库场景问题经典案例——分页优化
- js加强的经典分页
- VB.NET版的GridView经典使用(编辑,删除,分页,链接列)
- Mybatis+mySQL动态分页查询数据经典案例
- 分页 SQLServer存储过程
- [转载]sqlserver存储过程分页总结
- CI框架常用经典操作类总结(路由,伪静态,分页,session,验证码等)
- Google经典分页案例
- SQL Server 存储过程的经典分页
- oracle中的分页(最超级的,一分钟学会,经典的)
- 分页居中-圆角宽度自适应宽度(经典)
- 分页 SQLServer存储过程
- 超经典的存储过程分页 ;-) 引自CSDN网友所作
- php与oracle11g经典分页
- SQL Server 存储过程的经典分页
- 经典的分页完整程序+注释
- mybatis常用经典分页方法
- 经典数据库记录分页代码
- 我整理的一个经典分页程序(JSP的)
- SQLServer存储过程实现单条件分页