Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 IN

Author  Topic 

dcarva
Posting Yak Master

140 Posts

Posted - 2003-12-13 : 23:39:08
Hello, I have a string that comes into a stored procedure in this format.

'hello', 'happy', 'funny'

I can easily use this string to do things like:

WHERE string1 IN ( 'hello', 'happy', 'funny' )

But what I really need to do is:

WHERE string1 IN ( '%hello%', '%happy%', '%funny%' )

As if I was using LIKE. Is this possible? Hope this makes sense.

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2003-12-14 : 04:33:39
Hi

It doesn't exaclty work like that, you would need to go :

WHERE string1 like '%hello%' OR string1 like '%happy%' OR string1 like '%funny%'

Or, you can do something like this [1], which lets you pass a CSV of strings to a proc.

[1] http://www.sqlteam.com/item.asp?ItemID=5857




Damian
Go to Top of Page
   

- Advertisement -