I know it help it says update your query to retrieve the next 200 records, how do you set a loop to reach the end of record count?
Answer
Execute SQL results count
Best answer by fhunth
ROW_NUMBER() seems to work:
Paging with ROW_NUMBER()
DECLARE @PageNum AS INT;
DECLARE @PageSize AS INT;
SET @PageNum = 2;
SET @PageSize = 10;
WITH OrdersRN AS
(
SELECT ROW_NUMBER() OVER(ORDER BY OrderDate, OrderID) AS RowNum
,OrderID
,OrderDate
,CustomerID
,EmployeeID
FROM dbo.Orders
)
SELECT *
FROM OrdersRN
WHERE RowNum BETWEEN (@PageNum - 1) * @PageSize + 1
AND @PageNum * @PageSize
ORDER BY OrderDate,OrderID;
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.