sql 分页取数据的存储过程
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE Proc [g].[ListXXX] @pageNo int = 1, @pageSize int = 10 As Begin Declare @pageEnd int Declare @pageStart int Set @pageEnd = @pageNo * @pageSize Set @pageStart = (@pageNo - 1) * @pageSize Select * From ( Select Row_Number() Over(Order By CreateTime Desc) As Row ,[Id] ,[Status] ,[CreateTime] From XXX Where [Status] = 2 ) As x Where x.Row > @pageStart And x.Row <= @pageEnd Select Count(1) From XXX Where [Status] = 2 ) End
喜欢的朋友请帮忙点个赞!!!