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

Can anybody please point me in the right direction of searching the Pages library using FullTextSqlQuery? I've successfully instanced a new FullTextSqlQuery and have dealt with all of the necessary properties. It retrieves data just fine but as it stands my query is:

SELECT Title FROM Scope()

Simply for me to test it's working. How do I refine this to add a where a clause to search only Pages library?

share|improve this question
up vote 1 down vote accepted

If you're querying multiple Site Collections use FullTextSQLQuery since it searches across the farm and if you plan to query Pages Library of a single Site Collection, use SPSiteDataQuery instead. I think you might need SPSiteDataQuery?

    SPSiteDataQuery queryObj = new SPSiteDataQuery();      
    //query Pages libraries
    queryObj.Lists = "<Lists ServerTemplate='850' />"; 
    queryObj.ViewFields = "<FieldRef Name='Title' /><FieldRef Name='FileRef' />";
    queryObj.Webs = "<Webs Scope='Recursive' />";
    DataTable dt = SPContext.Current.Web.GetSiteData(query);

    foreach (DataRow row in dt.Rows)
        //do something else

P.S. FullTextSqlQuery may not always return the freshest of data but you can reduce the incremental crawl schedule to 15 mins or 30 mins.


Set the QueryText property of your FullTextSQLQuery object like this:

fullTextSqlQuery.QueryText =
"select title, ContentClass from scope() where (contentclass = 'STS_List_850')";

"STS_List_850": // denotes a Page Library

share|improve this answer
Thanks Falak. For a few reasons, it's been specified that I use a FullTextSQLQuery. Thanks anyway. – JᴀʏMᴇᴇ Jun 25 '12 at 12:20
Thanks a LOT Falak! – JᴀʏMᴇᴇ Jun 25 '12 at 12:33
I have update my response – Falak Mahmood Jun 25 '12 at 12:33

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.