Reputation: 409
How I display All data when parameters are null,
DECLARE @PageSize INT = 5
,@PageNo INT = 2
SELECT *
FROM [MyTable]
ORDER BY [NO]
OFFSET @PageSize * (@PageNo - 1) ROWS
FETCH NEXT @PageSize ROWS ONLY
Upvotes: 3
Views: 4289
Reputation: 5148
You could try this
SET @PageSize = ISNULL(@PageSize, 2147483647) -- max int
SET @PageNo = ISNULL(@PageNo, 1)
SELECT *
FROM [MyTable]
ORDER BY [NO]
OFFSET @PageSize * (@PageNo - 1) ROWS
FETCH NEXT @PageSize ROWS ONLY
Upvotes: 6