SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let's assume I have list with 100 items. Is it possible to write CAML query to get 5 items, but skip 10 items from the beggining? Something like LIMIT and OFFSET in SQL?

share|improve this question
up vote 2 down vote accepted

Unfortunately, SharePoint paging works a bit differently than LIMIT and OFFSET in SQL. To get paginated items you have to provide ID of the first item for the page you want and then set RowLimit, and if you have sorting defined for the list, you also have to provide sorting columns names and values of those columns for the first item on your page.

You can see how it works if you go to any list which has enough items and try to go through pages and see how the query string of the page changes. Then delete some items and try again. Then change order of items and try again...

All those params you will have to pass into ListItemCollectionPosition property of SPQuery object.

More about paging in SharePoint:

In your particular case, you can simplify things a bit, if you don't have filtering and sorting:

  1. Select first 11 IDs from the list
  2. Use 11th ID to create the correct ListItemCollectionPosition for your SPQuery
  3. Set RowLimit of the SPQuery object to 5

To quickly select top 11 IDs, use this query:

var query = new SPQuery()
    ViewFields = "ID",
    ViewFieldsOnly = true,
    IncludePermissions = false,
    RowLimit = 11
share|improve this answer
so in other words... the paging is unusable because you just cant skip to page number 10 for example... sweet – Michal Hainc Jun 22 '15 at 7:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.