One workaround I've seen:
WHERE charindex(',' + cast(b.group_category_id as varchar) + ',', @ParamList) > 0
In this case, @ParamList will be a string in the form ", 4,12,45,23,"
This is not “beautiful,” but it retains the parameter and benefits of a compiled query. Since you are looking for numbers, the substring guarantees a unique match.
Ruslan
source share