Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help - finding values in variables in T-SQL 1

Status
Not open for further replies.

Kieran777

Programmer
Apr 23, 2003
26
AU
I have a Variable with a list of items (see @a) below. I need to be able to check the variable to see if an item is in the list and the perform relevant action. How can you do this in T-SQL. eg something like below code - but that doesn't work.


declare @a varchar(80)
set @a = 'xxx' + ',' + 'yyy'
if 'xxx' in (@a)
print 'Its There!'
else
print 'Its NOT There!'
print 'A=' + @a

Print 'Also Tried this with no luck'
set @a = char(39) + 'xxx' + char(39) + ',' + char(39) + 'yyy' + Char(39)
if 'xxx' in (@a)
print 'Its There!'
else
print 'Its NOT There!'
print 'A=' + @a

print 'How do I get it to find ' + char(39) + 'xxx' + char(39) + ' in ' + @a + '?'

Any help appreciated.
cheers
B-(

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top