Solved

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

Posted on 2013-05-29
5
349 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 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 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

AWS Certified Solutions Architect - Associate

This course has been developed to provide you with the requisite knowledge to not only pass the AWS CSA certification exam but also gain the hands-on experience required to become a qualified AWS Solutions architect working in a real-world environment.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
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.

631 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