Monday, December 26, 2011

FullTextSQL query in Sharepoint

Here is the sample on how to use FullTextSQLQuery in Sharepoint


DataTable queryDataTable = new DataTable();
                FullTextSqlQuery myQuery = new FullTextSqlQuery(serverContext);


                myQuery.QueryText = "SELECT FirstName,LastName,MobilePhone,JobTitle FROM scope() WHERE  \"scope\" = 'People' and (MobilePhone like '%" + key + "%' )";

                myQuery.ResultTypes = ResultType.RelevantResults;
                myQuery.RowLimit = 10;

                ResultTableCollection queryResults = myQuery.Execute();
                ResultTable queryResultsTable = queryResults[ResultType.RelevantResults];
                int intTotalRecords = queryResultsTable.TotalRows;
                queryDataTable.Load(queryResultsTable, LoadOption.OverwriteChanges);

No comments:

Post a Comment