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

when I debug i can see URL is valid (like below). Shared Documents is tie a to custom content type.

string fileURL = "Shared Documents/Marketing Folder/Sales_Report.txt";
oQuery.Query = @"<Where>
                   <FieldRef Name='URL' />
                   <Value Type='Text'>" + fileURL + @"</Value> 
oQuery.ViewAttributes = "Scope=\"Recursive\"";

I tried , , all variation but NO SUCCESS. I am so feedup. I wish Microsoft would provide a validation tool for these types.

The url does not show up in the drop when i use u2u.

The following code gives me all the items in the Shared Documents.

            oQuery.Query = @"<Contains>
                                 <FieldRef Name='URL' />
                                 <Value Type='URL'>" + fileURL + @"</Value> 
share|improve this question
You definitely have a column called URL, yeah? A malformed CAML query will return all items. – James Love Mar 23 '11 at 18:53
@James: Are you certain that I have to create a column "URL" and populated it "Relative URL". hmm, as I understood from somewhere it's already there by default (where you it's visible or not with sp gui or u2u caml builder or sp manager). I went to SQL db for the content db and i see that tp_DirName is populated with Relative URL. select * from alluserdata where tp_leafname='Sales_Report.txt' – user2556 Mar 24 '11 at 14:04
up vote 0 down vote accepted

I found the answer on this forum. The u2u caml builder is not sophiscated enough to turn on the recursive mode. So the code worked when I put it in the console app (with query ViewAttributes recursive mode).

sites/SiteCollection/SubSite/Site Documents/Excel Report.xls

share|improve this answer

Your Answer


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