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

I came into a situation where I wanted to use SharePoint Object Model SPSiteDataQuery to query data from Publishing Page.

However, I dont want the data query based on the permission on current login user, the query has to be query only the published version (last major version), regardless the permission of current login user.


login user is reader, contributor or full control, the query data should be only published version.

if the page is draft (0.1), no data will be query.

if the page is draft (1.1), data on version 1.0 will be query.

below is the sample code fragment on SPSiteDataQuery:

using(SPSite site = new SPSite("http://server"))
    using(SPWeb web = site.OpenWeb())
        SPSiteDataQuery query = new SPSiteDataQuery();

        query.Lists = "<Lists ServerTemplate=\"850\" />";
        query.Webs = "<Webs Scope='Recursive' />"; 
        query.ViewFields = "<FieldRef Name='Title' />";
        query.Query =  "<Where><Gt><FieldRef Name='ID' /><Value Type='Number'>0</Value></Gt></Where>";

         dt = web.GetSiteData(query);

my question is, can SPSiteDataQuery able to query only the published version of data?

perhaps query by View or any other property can help?

or change in CAML query able to achieve this?

any workaround on this?

thank you in advanced.

share|improve this question

You may try adding following condition in the query:

<FieldRef Name=\"_Level\" /><Value Type=\"Integer\">1</Value>
share|improve this answer
This seems to filter an item being edited, but the query does not return its original version before being edited. – John_ Dec 27 '13 at 12:42

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.