SQL2005结合ROW_NUMBER()高效分页存储过程

SQL2005结合ROW_NUMBER()高效分页存储过程:
CREATE PROCEDURE [dbo].[sp_Accounts_GetUserListPaged]
    @PageIndex INT,
    @PageSize INT
AS

BEGIN

WITH UserList AS (
SELECT ROW_NUMBER() OVER (ORDER BY RegDate DESC)AS Row, * FROM Accounts_Users)

SELECT *
FROM UserList
WHERE Row between (@PageIndex - 1) * @PageSize + 1 and @PageIndex*@PageSize

END

posted @ 2007-08-01 10:58  scgw  阅读(676)  评论(0编辑  收藏  举报