Just a brief demo of dynamic use of OFFSET through a loop

Oopps! Upgrade your browser pretty please.Oopps! Upgrade your browser pretty please.
DECLARE— Let us declare variables:
  @count int = 0,— Start
  @to int,— End
  @rows int = 10;— Rows per set
SELECT— Now we’re gonna
  @to = count(*) / @rows— determe the number of sets
FROM sys.columns— from this table
WHILE @count <= @to— This loops all through to the last set
  SELECT— Returning these
    *— columns
  FROM sys.columns— from this table
  ORDER BY 1 ASC— in this order (here just based on first column).
  OFFSET (0 + (@count * @rows))— Based on loop we get the starting point of the offset.
  ROW FETCH NEXT (@rows) ROWS ONLY— The number of rows we’re fetching!
  SET @count += 1— Next step!