New tsql commands in Sql Server 2012 (Part 3)Posted: 04/01/2012
In the new version of the sql server 2012 it is possible to easily implement paging. To do so you need the offset x rows command (x defines the starting row of your query) and the fetch next x rows only command. (x defines the rowcount of your query).
declare @counter int = 0 while(@counter < 50) begin select id, data, iif(id <= 5, 'small', 'big') from testData order by id offset @counter ROWS FETCH NEXT 5 ROWS ONLY; set @counter = @counter + 5; end