Solved

keyword search in stored procedure

Posted on 2009-05-17
3
239 Views
Last Modified: 2012-05-07
We need a stored procedure that list tall he recordset with a given column containing specified keywords (please not the s:).
For example, MyTable contains the column MyMemo, and we need all the recordsets having 'john' AND 'eat' keywords. Keyword can be passed to the stored procedure thru a string like 'john,eat' with a given separator or thru xml format so we can use some request "from @xmlkeywords.nodes" stuff.
Thanks for help








0
Comment
Question by:javilmer
[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
3 Comments
 
LVL 5

Expert Comment

by:Aanvik
ID: 24406279
Try this.
declare @newString varchar(205)
Set @newString = '%Test%'
-- Insert statements for procedure here
select so.name from sysobjects so join syscomments sc on so.id = sc.id 
where sc.text like @newString
order by name

Open in new window

0
 

Author Comment

by:javilmer
ID: 24406580
I dont' think it will work with more than one keywords...
0
 
LVL 60

Accepted Solution

by:
chapmandew earned 500 total points
ID: 24408474
you can do this:

declare @x xml, @newx varchar(1000)
set @x = '<search><val>john</val><val>eat</val></search>'

select * from tablename g
where exists(
select 1
from @x.nodes('/search/val') t(c)
where g.mymemo like '%' + c.value('.', 'varchar(100)')  + '%')
0

Featured Post

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

737 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