my stored proc receive “@CatergoryIDs varchar”
@CatergoryIDs contains single or multiple IDs separated by “|”,
my stored proc look like this :
Select R.ID,,CategoryID, (sum(C.Rating)/Count(R.ID)) as "Rating"
from Table1 R
left outer join Table2 C
ON R.ID = C.ID
GROUP BY R.ID
having R.CategoryID = @CatergoryID
RETURN
You should be able to use
CHARINDEX. However, this is very inefficient, it would be better to have@CategoryIDas a table variable.