Solved

IN sql server 2005 how to write a function to find words in a sentence.

Posted on 2009-07-10
2
237 Views
Last Modified: 2012-05-07
for example
create function find_qualification_exists(@name varchar(65))

the @name is included with qualification. for example : 'Mark Froster MA, CRC,CCM,RN'.
i have the qualifications list. ('abc','xxx','ccm','rn','crc','xyz','lmn','opq')
Now i need to write a query to check whether/not the @name has at least one qualication.

Function should return 'yes' if qualification exists or 'no' if not.
0
Comment
Question by:nreich
2 Comments
 

Author Comment

by:nreich
ID: 24825914
i need to write a query to check whether/not the @name has at least one qualication from the list given.
0
 
LVL 41

Accepted Solution

by:
ralmada earned 100 total points
ID: 24826195
Can you put the qualification in a temp table? then you can give this a try
declare @name varchar(50)
 
set @name = 'Mark Froster MA, CRC,CCM,RN'
 
 
declare @ttable (
quali varchar(10)
)
 
 
insert @ttable
value ('abc')
...
 
 
select top 1 case when patindex('%'+quali+'%', @name) = 0 then 'No'
	else 'Yes' end as result
from @ttable
order by 1 DESC

Open in new window

0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need some help to cast ntext to nvarchar SQL 2000 7 37
VB.net and sql server 4 45
Syntax Issue with SSIS module 26 100
SQL Server group with two values 4 34
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

789 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