SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

Maybe a simple question, when to use CamlQuery and when to use SPQuery ?

I think that SPQuery is used inside a WebPart running on the SharePoint server, and that CamlQuery is part of the Client Object Model which is used when you connect from a client (CLI, Asp.Net or custom Web Service) to a SharePoint site.

share|improve this question
up vote 2 down vote accepted

Yes that's right. CamlQuery is a class in the Microsoft.SharePoint.Client.dll which is part of the Client Object Model which can be used through a .NET, Silverlight or JavaScript Application.

While SPQuery is part of the Microsoft.SharePoint.dll which can be used on the Server Side in Farm or Sandbox solutions through Custom C#/.NET code.

share|improve this answer

You're right SPQuery is part of the Server Side API and CamlQuery is part of the Client Object Model.

So if your code is running on a server in the SharePoint Farm you can use SPQuery.

If your code isn't running on one of the servers, then you can use CamlQuery.

share|improve this answer

While using CAMLQuery in COB -> make sure you enclose your query with and ofcourse the closure tag - as this is not SPQuery.Query

In CAMLQuery its ViewXML -> not a Query !

my 1 cent !

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.