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 am trying to check if a filename exists in the 'Name' column of Shared Docs Library. I think only CAML could help here. So I made this query

"<Where><Eq><FieldRef Name='Name' /><Value Type='Text'>" + docname + "</Value></Eq></Where>"

But I get this error One or more field types are not installed properly. Go to the list settings page to delete these fields.

 string docname = "Disabled Service";  
        StringBuilder sb = new StringBuilder();  
        sb.Append("<Where><Eq><FieldRef Name='Name' /><Value Type='Text'>"+docname+"</Value></Eq></Where>");  
        SPQuery spq = new SPQuery();  
        spq.Query = sb.ToString();  
        spq.RowLimit = 1;  
SPList list = web.Lists["Shared Documents"];  
                    DataTable dt = list.GetItems(spq).GetDataTable();  

Kindly help..

share|improve this question
got it with "FileLeafRef" Thanks – sanju May 6 '12 at 17:26

The internal name of Name is FileLeafRef so your query should be:

"<Where><Eq><FieldRef Name='FileLeafRef'/><Value Type='File'>" + docname + "</Value></Eq></Where>"

If you don't like building the query by hand then a couple of good tools are:
- U2U CAML Query Builder which gives you an UI for building the query.
- CAML.NET which is a library for safely building CAML queries

share|improve this answer
And there's also the Stramit CAML Viewer, – Eric Alexander May 7 '12 at 12:44
I'd be curious to know how you find a list of the correct names for fields to use in CAML? Title is "Title" but Name is actually "FileLeafRef"? What gives? – Ray Nov 22 '12 at 23:00

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.