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