I am trying to find a way to query rows of data by using a "multivalue" pipe delimited column in another table as a WHERE clause. SQL SERVER 2005
This is my best description of the problem:
Imagine a pipe delimited column set to a variable like @LIST = 'Bob|Mary|Joe'
then I am trying to find a match like this
Select * from Users where FirstName = 'Joe'
but extended to be
Select * from Users where FirstName "IS CONTAINED IN" @List
which would return all the Bob, Mary and Joe entries. Thanks for your help.
You can use a split udf and join it to your main query. see this link for the code and an example. Your query would end up looking like this. This is untested but hopefully this points you in the right direction.
Select A.* from Users A JOIN dbo.Fn_Split(@ValueArrayString, '|') B on A.FirstName = B.value