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?

1 Answer 1


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

  • Thanks Falak. For a few reasons, it's been specified that I use a FullTextSQLQuery. Thanks anyway. Jun 25, 2012 at 12:20
  • 1
    I have update my response Jun 25, 2012 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.