I have a varchar field that contains a string like "10,11,12,13". How can I use that CSV string to join to another table with those IDs? Here's the approach I'm taking now:
select *
from SomeTable a
WHERE (',' + @csvString + ',') LIKE '%,' + CONVERT(varchar(25), a.ID) + ',%'
Where @csvString is "10,11,12,...". I intend to use this method as a join condition as well.
That method works, but it's rather slow (using CAST doesn't improve the speed).
I understand that having CSVs in the database like that is usually a very silly idea in most cases, but there's nothing I can do about that.