I have a table with a varchar column categoryIds. It contains some IDs separated by commas, for example:
varchar
categoryIds
id categoryIds -----
You could use dynamic SQL like this:
DECLARE @categoryIds nvarchar(50) = '1, 2, 3, 4, 5' EXEC ('SELECT * FROM myTable WHERE categoryId IN (' + @categoryIds + ')')