How to page using stored procudure.
来源:互联网 发布:发淘宝密令的群 编辑:程序博客网 时间:2024/05/20 14:25
An example t paging result using stored procudure.
USE [LBY]
GO
/****** Object: StoredProcedure [dbo].[UserPaged] Script Date: 07/15/2011 10:21:37 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[UserPaged]
( @PageIndex int, @PageSize int )
AS 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 int )
-- Insert into the temp table
INSERT INTO #PageIndex
SELECT ID FROM Users ORDER BY ID DESC
-- Return total count
SELECT COUNT(ID) FROM Users
-- Return paged results
SELECT O.* FROM Users O, #PageIndex PageIndex
WHERE O.ID = PageIndex.ID
AND PageIndex.IndexID > @PageLowerBound
AND PageIndex.IndexID < @PageUpperBound
ORDER BY PageIndex.IndexID
END
GO
- How to page using stored procudure.
- How to call Oracle function or stored procedure using spring persistence framework?
- How to call an Oracle Stored Procedure that returns one or more REF CURSORS, using ADO from C++ How
- Using JDBC to Execute Stored Procedures
- navicate how to create a stored procedure
- navicate how to create a stored procedure
- How to call stored procedure in Hibernate
- How to call stored procedure in Hibernate
- How to hide & unhide the grid from the page by using people code?
- How to Using exploits.
- How to using TOR
- HOW TO: Using CVS
- How to Using Theano
- How to Bypass Search Page
- How to programmatically assign a SkinID to a control while using a master page in ASP.net 2.0
- How To Convert HTML Page To Image
- illustrates how to call a SQL Server stored procedure
- How to debug stored procedure/function in TOAD
- 求无向图的连通分量 算法
- js+div+css
- How to enable the IntelliSense of SQL Server 2008
- C/C++中涉及存储方式的关键字:auto,static,register,extern
- 插入,冒泡排序算法,二分查找
- How to page using stored procudure.
- 处乱不惊,临危自若。
- 考研政治顺口溜————独乐乐,不如众乐乐
- android开发环境配置
- HDU 3594 Cactus 图的强联通 tarjan
- java核心技术之 ArrayList应用 【职员薪水管理系统】
- 线程同步
- 突然想起还有这个博客
- ThreadLocal实现线程范围内的数据共享