We can easily implement paging in SQL server 2008 , 2005 .
Create PROC ProcedureName @PageSize int, @PageNumber int As Begin declare @RowStart int,@RowEnd int SET @PageNumber = @PageNumber -1 SET @RowStart = @PageSize * @PageNumber + 1; SET @RowEnd = @RowStart + @PageSize - 1 ; With TEMPTABLE AS ( SELECT *, ROW_NUMBER() OVER (order by ID) as RowNumber FROM TABLENAME where YOUR MATCHING CONDITION) select * from TEMPTABLE Where RowNumber >= @RowStart and RowNumber <= @RowEnd End
In above procedure we have create a temporary table , which is used to restore all the data with row number . With the help of row number we have create page according to page size and starting of the page number.