Solved

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

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

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:
huslayer 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 31

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now