Solved

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

Posted on 2009-07-10
2
247 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
[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
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 Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how would you excute a sproc on another database on the fly 9 35
SQL to JSON 14 64
UPDATE JOIN multiple tables 5 34
Display SQL maintenance plan SQL Code 3 44
As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
'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 …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
Suggested Courses

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