?
Solved

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

Posted on 2004-09-04
1
Medium Priority
?
517 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 1000 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
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.
Suggested Courses

770 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