I want the stored procedure to accept x the number of data lines for the page y-number. for instance
I have 20 datarow my page size is 2 if I select page 2 I get a data row 17,18
I can use the top 200 and use the order to select the first and last datarow, but how do I get the pages between them.
@PageNumber INT As BEGIN SELECT COUNT(rate.RateID)/200 FROM dbo.Rate where dbo.Rate.Hourly =0 DECLARE @LastIndex INT SET @LastIndex= (SELECT TOP 1 rate.RateID FROM dbo.Rate where dbo.Rate.Hourly =0 ORDER BY rate.RateID ASC) Select TOP 200 [RateID], [PairID], [Open], [Close], [High], [Low], [Difference], [Average], [Percentage], [InfoDate], [Hourly], [CaptureDateTime] From Rate WHERE Hourly =0 AND RateID >=(@LastIndex+(200* @PageNumber)) ORDER BY [RateID] ASC
The end is what I have now, but it is not working properly
source share