I have to work with a potentially large list of records and I\'ve been Googling for ways to avoid selecting the whole list, instead I want to let users select a page (like f
Here's an updated version of @RoadWarrior's code, using TOP. Performance is identical, and extremely fast. Make sure you have an index on TestTable.ID
CREATE PROC dbo.PagingTest
@SkipRows int,
@GetRows int
AS
DECLARE @FirstId int
SELECT TOP (@SkipRows)
@FirstId = [Id]
FROM dbo.TestTable
ORDER BY [Id]
SELECT TOP (@GetRows) *
FROM dbo.TestTable
WHERE [Id] >= @FirstId
ORDER BY [Id]
GO