How to write a CAML Query so that the result contains Column1 and Column2

camlsharepoint

My below code is used for filtering based on ID:

camlQuery = xmlDoc.CreateElement("Query");

                camlQuery.InnerXml = "<Where><Gt><FieldRef Name='ID'/><Value Type='Number'>0</Value></Gt></Where>";

How to write a CAML Query so that it returns (the result contains) Column1 and Column2?

I'm new to CAML Queries, maybe it's not possible to filter and say only certain columns should be returned?

The problem is that when I run the above query, it returns all the SharePoint columns of my list (42), whereas I only need 2-3.

Thanks,

Best Answer

You have to use the SPQuery.ViewFields property.

Related Topic