Solved

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

Posted on 2004-09-04
1
508 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
1 Comment
 
LVL 9

Accepted Solution

by:
solution46 earned 500 total points
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
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 INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now