I have an existing stored procedure that currently has a default TOP (@numRows) with a default set to limit the record set if no value is provided.
I've changing this proc to support paging by adding
to the end which means I can no longer use a TOP but I still want to cater for default values.
I can get the same limited, default record set by doing
but I can't work out how to logically get that solution programmatically.
Ideally I'd want something equivalent of
Any ideas?
I've changing this proc to support paging by adding
Code:
OFFSET @PageSize * (@PageNumber - 1) ROWS
FETCH NEXT @PageSize ROWS ONLY
to the end which means I can no longer use a TOP but I still want to cater for default values.
I can get the same limited, default record set by doing
Code:
OFFSET 0 ROWS
FETCH NEXT @PageSize ROWS ONLY
but I can't work out how to logically get that solution programmatically.
Ideally I'd want something equivalent of
Code:
@PageSize int = 0
IF @PageSize = 0
OFFSET 0 ROWS
FETCH NEXT 100 ROWS ONLY
ELSE
OFFSET @PageSize * (@PageNumber - 1) ROWS
FETCH NEXT @PageSize ROWS ONLY
Any ideas?