set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
Create PROCEDURE [dbo].[aspnet_Customer.Msg_GetMsgByProfileId]
(
@PageSize INT,
@PageIndex INT,
@ProfileId INT
)
AS
BEGIN
DECLARE @PageLowerBound INT;
DECLARE @PageUpperBound INT;
DECLARE @TotalRecords INT;
DECLARE @TotalRecords INT
SET @PageLowerBound=@PageSize * (@PageIndex-1);
SET @PageUpperBound = @PageSize - 1 + @PageLowerBound;
WITH MyMsg AS
(
Select ROW_NUMBER() OVER(ORDER BY ID DESC) AS Rownum,
Id,Msg,Status FROM Customer.Msg Where @ProfileId=ProfileId
)
Select Id,Msg,Status
FROM MyMsg
Where Rownum>=@PageLowerBound AND Rownum<=@PageUpperBound;
@TotalRecords=@@ROWCOUNT
END