Solved

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

Posted on 2004-09-04
1
511 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
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
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…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

910 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

20 Experts available now in Live!

Get 1:1 Help Now