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

Every SPQuery's query should have

<View><Query> query...  </Query></View>


Sometimes I have to put without those tags to get it work and some times I have to put it with the tags, why is this?

share|improve this question
up vote 7 down vote accepted

If you read these two pages, you'll see that the two different properties require different structure.

You'll see that ViewXML is the full Query, thus needs the View and Query tags, whereas the Query property is just the "filter" part of the query. SPQuery internally builds up the View and Query elements around the Query property to produce the full CAML Query which appears as the ViewXML property.

share|improve this answer

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.