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