Solved

tsql check if a word is founded in an array of word ..

Posted on 2013-05-29
5
345 Views
Last Modified: 2013-06-20
for example i have an array contain set of words
i want to check if the variable @word is founded in the array contains set of word
please can you declare of me a array contain set of word and what function or if statement should be witted to check in @word is in @arrayofword
0
Comment
Question by:afifosh
[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
5 Comments
 
LVL 48

Expert Comment

by:PortletPaul
ID: 39204100
an "array"?
do you have at least one table involved?
please provide us with some more details of what the database stores (e.g. a table) otherwise we are totally guessing.
0
 
LVL 32

Expert Comment

by:awking00
ID: 39204539
Since we're guessing -
where patindex(@word,@arrayof word) > 0
0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 39204861
what I'm understanding is

declare @str1 varchar(500)
set @str1 = 'angel,sage,master,wizard'

select charindex('master',@str1) 

Open in new window

0
 
LVL 21

Accepted Solution

by:
Jason Yousef, MS earned 500 total points
ID: 39223165
Not sure what you mean but the result in a new array
what I'm understanding is:
Declare @word varchar(100),
             @arrayofword  varchar(1000)

select @word = 'visit' , @arrayofword = 'jason, test, visit'

select charindex(@word,@arrayofword) 

Open in new window

0
 
LVL 32

Expert Comment

by:awking00
ID: 39223233
Selecting charindex [or patindex] (@word,@arrayofword) would produce 12 and 14 respectively for the last two offered solutions, so I think what you're looking for is more like select <whatever> where charindex((@word,@arrayofword) > 0
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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. …
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

732 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