Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

keyword search in stored procedure

Posted on 2009-05-17
3
Medium Priority
?
241 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 2000 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

There are some very powerful Dynamic 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 di…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

715 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