Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Server $ function
Message
From
12/12/2012 12:21:58
Gary Foster
Pointsource Consulting LLC
Chanhassen, Minnesota, United States
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Miscellaneous
Thread ID:
01559422
Message ID:
01559438
Views:
52
Thanks Naomi,

This works for my problem, but sometimes I have to look in a string of values.
It would be nice if there was a way to loom in a string of values.

Gary

>>Hi,
>>
>>I'm trying to find if a string exists as part of another string like the $ operator in Fox. I'm using this in a CASE statement.
>>
>>I need to use a variable for the right hand side of the comparison and can't get it to work for the life of me!
>>
>>Works fine:
>>if exists(select 1 where 'anc' in ('anc','add','xxx'))
>>
>>Fails miserably:
>>declare @MyList varchar(20)
>>-- Code to build list...
>>print @MyList
>>displays 'anc','add','xxx'
>>
>>if exists(select 1 where 'anc' in (@MyList)) -- Fails
>>
>>Perhaps I'm not building my list string properly?
>>
>>Thanks.
>
>Try
>
>declare @MyList table (Descr varchar(10))
>insert into @MyList values ('anc'),('add'),('xxx')
>
>if exists (select 1 where 'anc' in (select Descr from @MyList))
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform