Apply paging in procedure
@intPageId int,
@intPageSize int
select * from (
Select row_number() over (order by TableA.intID asc ) r,
TableA.intID,tableA.hName,TableB.Address
from TableA
Join TableB on TableA.intid = TableB.intId
) A
where A.r between ( (@intpageid-1)*@intpagesize)+1 and ((@intpageid-1)*@intpagesize)+@intpagesize
The query in bold text is for paging, and the normal text query is that which returns your records.
OR
SELECT * from PressRelease
order by CreatedDate desc
OFFSET (@PageID-1)*@PageSize ROWS
FETCH NEXT @PageSize ROWS ONLY
DECLARE @pageID INT =2
ReplyDeleteDECLARE @pagesize INT=10
SELECT MarketId,MarketName
FROM dbo.Market
ORDER BY MarketId
OFFSET (@pageID-1)*@pagesize ROWS
FETCH NEXT @pagesize ROWS ONLY
Offset skips number of rows from top that you mention and
FETCH NEXT pull number of rows that you mention