I have the following string.
car, bus, bike, house
I would like to split these into individual strings and use them in a where clause so it would like this:
SELECT [text]
FROM [table]
WHERE
text LIKE 'bus'
or text LIKE 'car'
or text LIKE 'bike'
or text LIKE 'house'
How would you go through the original string and split them out into individual substrings. The original text string is being passed as variable from a GUI. So far we have this
REPLACE(LEFT('%BIKE, BUS, HOUSE%',CHARINDEX(',','%BIKE, BUS, HOUSE%')),',','%'),
REPLACE(SUBSTRING('%BIKE, BUS, HOUSE%',CHARINDEX(',','%LADDER, BA%'),LEN('%BIKE, BUS, HOUSE%')),',','%'),
But that only brings back a substring before the first comma and keeps everything after. eg 'bike' and 'car, bus, house'.
Any ideas?