Solved

Boolean Search - ASP.NET & SQL Server ---500 points

Posted on 2004-09-04
1
515 Views
Last Modified: 2009-02-02
Currently I have search functionality on my ASP.NET pages, which does a "LIKE" search against multiple tables, multiple fields.  We need to change this functionality to support Boolean search.  Say, the user would like to type "oranges AND apples OR grapes NOT peaches" in the search text box, where AND, OR, and NOT are considered Boolean identifiers.  Note: Fulltext search isn't an option. So I'm trying to parse the search string in the stored procedure to construct the WHERE CLAUSE. Remeber search is on 5 tables over 50 columns...

Experts please give some stored procedure script to create WHERE CLAUSE based on the Boolean Search String.
0
Comment
Question by:sandydb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 9

Accepted Solution

by:
solution46 earned 500 total points
ID: 11984009
sandydb,

can I suggest a different way of doing this?

Give your users a grid in ASP, along the following lines...

         Open Brackets   Field            Operator     Value          Close Brackets       <--- table headings
AND   <check box>    <SELECT>   <SELECT>  <TEXT box> <check box>          <--- rows

You can then loop through each row in ASP building the WHERE clause as you go, and send the resulting string to SQL Server.

Otherwise, I think you will find it much easier to parse it in ASP before sending it to SQL Server.

In your sproc, have an input parameter, e.g. @WHERE, and use...
SET @SQL = 'SELECT blah blah...'
SET @SQL = @SQL + 'FROM blah blah...'
SET @SQL = @SQL + @WHERE

EXEC((@SQL))


s46.
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question