• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

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

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.
1 Solution
nreichAuthor Commented:
i need to write a query to check whether/not the @name has at least one qualication from the list given.
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

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now