Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-05-29
5
Medium Priority
?
352 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
5 Comments
 
LVL 49

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 1500 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to shrink a transaction log file down to a reasonable size.

824 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