分页存储过程
来源:互联网 发布:淘宝网衣服女装图片 编辑:程序博客网 时间:2024/05/15 23:46
CREATE PROCEDURE pro_select
@PageIndex INT,
@PageSize INT
AS
/*
select student.sno,student.sname,student.ssex ,grade.math,grade.physics,grade.huaxue,grade.Chinese,grade.English
from student,grade
where student.sno=grade.sno
*/
declare @NumResults int
select @NumResults = count(student.sno)
from student,grade
where student.sno=grade.sno
if (@PageIndex >= 0 and @PageIndex < ((@NumResults/@PageSize) +1))
begin
DECLARE @PageLowerBound int --查询记录开始处
DECLARE @PageUpperBound int --查询记录结束处
DECLARE @RowsToReturn int --返回的实际记录数
-- First set the rowcount
-- 设置返回的实际记录数
SET @RowsToReturn = @PageSize * (@PageIndex + 1)
SET ROWCOUNT @RowsToReturn
-- Set the page bounds
-- 设置查寻范围
SET @PageLowerBound = @PageSize * @PageIndex
SET @PageUpperBound = @PageLowerBound + @PageSize + 1
-- Create a temp table to store the select results
-- 创建临时表存放查询结果
CREATE TABLE #PageIndex
(
IndexId int IDENTITY (1, 1) NOT NULL,
id bigint --查询表的主键(可更改1)
)
-- Insert into the temp table
-- 向临时表存放查询表的所有主键
INSERT INTO #PageIndex (id)
SELECT
student.sno --(可更改2)
FROM --(可更改3)
student,grade
where student.sno=grade.sno
select a.sno,a.sname,a.ssex ,b.math,b.physics,b.huaxue,b.Chinese,b.English
from student a,grade b,#PageIndex PageIndex
where
a.sno=b.sno and
a.sno = PageIndex.id AND --(可更改8)
PageIndex.IndexID > @PageLowerBound AND
PageIndex.IndexID < @PageUpperBound
drop table #PageIndex
end
GO
- orcale分页 存储过程分页
- 一个分页存储过程
- 一个分页存储过程
- 存储过程分页代码
- 分页存储过程
- 数据库分页存储过程
- 分页存储过程
- 一个分页存储过程
- 分页 SQLServer存储过程
- 分页 SQLServer存储过程
- 存储过程分页
- SqlServer分页存储过程
- 分页的存储过程
- 通用分页存储过程
- sql 存储过程分页
- 分页存储过程
- 分页存储过程2
- 分页的存储过程
- 上下导航
- 简单验证码的识别
- JAVASCRIPT 类
- Delphi2006中配置Windows Mobile 5.0开发环境
- 小小黑白片
- 分页存储过程
- 关于tomcat配置的几点心得
- Spring的核心机制依赖注入简介(1)
- 数组的排序学习!!
- 神婆
- c#.net常用函数和方法集
- URAL
- 请不要做浮躁的嵌入式系统工程师
- Spring的核心机制依赖注入简介(2)