matthew Zhang

慢慢学习,慢慢进步!
  博客园  :: 首页  :: 新随笔  :: 订阅 订阅  :: 管理

SQL2005 存储过程分页

Posted on 2008-11-13 11:03  matthewZhang  阅读(301)  评论(0编辑  收藏  举报
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

-- =============================================
--
Description: 通用存储过程分页
--
@PageIndex: 当前页码
--
@PageSize: 每页显示的记录条数
--
=============================================
ALTER PROCEDURE [dbo].[GeneralSPOfPaging]
-- Add the parameters for the stored procedure here
@PageIndex int ,
@PageSize int
AS

BEGIN

SET NOCOUNT ON;

SELECT
*
FROM
(
SELECT
ROW_NUMBER()
OVER (ORDER BY HeTID DESC)AS Row
,
*
FROM
dbo.ECS_HeT
)
as list
WHERE
Row
between
(
@PageIndex - 1) * @PageSize + 1
and
@PageIndex*@PageSize
END