Skip to content

Instantly share code, notes, and snippets.

@dnasca
Created January 27, 2016 08:12
Show Gist options
  • Save dnasca/67b0ffb6c806d9a0e348 to your computer and use it in GitHub Desktop.
Save dnasca/67b0ffb6c806d9a0e348 to your computer and use it in GitHub Desktop.
query paging
-- returning the first 25 rows
SELECT
e.FirstName,
e.LastName,
e.AddressLine1
FROM
HumanResources.vEmployee AS e
ORDER BY
e.LastNAme, e.FirstName
OFFSET 0 ROWS
FETCH NEXT 25 ROWS ONLY;
-- paging through the next 25 rows
SELECT
e.FirstName,
e.LastName,
e.AddressLine1
FROM
HumanResources.vEmployee AS e
ORDER BY
e.LastNAme, e.FirstName
OFFSET 24 ROWS
FETCH NEXT 25 ROWS ONLY;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment