Solved

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

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
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 setup several different housekeeping processes for a SQL Server.

828 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