nedash says:
ALTER PROCEDURE [dbo].[NewOrder_Information]
@PageIndex INT = 1
,@PageSize INT = 5
,@RecordCount INT OUTPUT
AS
BEGIN
SELECT ROW_NUMBER() OVER(ORDER BY (SELECT 0) ASC)AS RowNumber,PeygiriCode,PostType,NAME,id,Quantity,Tell,address,date
INTO #Results
FROM (SELECT ROW_NUMBER() OVER(PARTITION BY PeygiriCode ORDER BY id ASC) RNo,PeygiriCode,PostType,NAME,id,Quantity,Tell,address,date FROM Order_Users)a
WHERE RNo = 1
SELECT PeygiriCode,PostType,NAME,id,Quantity,Tell,Address,date FROM #Results
WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1
END
Change with the below query
ALTER PROCEDURE [dbo].[NewOrder_Information]
@PageIndex INT = 1
,@PageSize INT = 5
,@RecordCount INT OUTPUT
AS
BEGIN
SELECT ROW_NUMBER() OVER(ORDER BY (SELECT 0) ASC)AS RowNumber,PeygiriCode,PostType,NAME,id,Quantity,Tell,address,date
INTO #Results
FROM (SELECT ROW_NUMBER() OVER(PARTITION BY PeygiriCode ORDER BY id ASC) RNo,PeygiriCode,PostType,NAME,id,Quantity,Tell,address,date FROM Order_Users)a
WHERE RNo = 1
SELECT @RecordCount = COUNT(*) FROM #Results
SELECT PeygiriCode,PostType,NAME,id,Quantity,Tell,Address,date FROM #Results
WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1
END