set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[NewChangshiPage]
-- Add the parameters for the stored procedure here
@PageSize int,
@PageIndex int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
with Changshi as(select *, ROW_NUMBER() OVER (order by ChangshiId desc) as Row from TableChangShi)
SELECT * from Changshi where Row between (@PageIndex-1)*@PageSize+1 and @PageSize*@PageIndex
END
仅用两行代码便可搞定。大家如果有什么更好的意见,请多多留言哦。