अगर आपका @ServiceActivity
कुछ इस तरह है 1,2,3
आप ऐसा कुछ कर सकते हैं
WHERE `,1,2,3,` LIKE `%,1,%`
इसलिए आप अपने वैरिएबल को फ़ॉर्मैट करें
WHERE ',' + @ServiceActivity + ',' LIKE '%,' + ID + ',%'
SELECT *
FROM
(SELECT '1,2,3,4' as X UNION ALL
SELECT '2,3,4,5' as X UNION ALL
SELECT '3,4,5,6' as X UNION ALL
SELECT '1,3,4,5' as X
) as T
WHERE ',' + X + ',' LIKE '%,1,%'
आपके मामले के लिए
(CASE WHEN @YESNOActivity = 'Yes'
THEN ',' + @ServiceActivity + ','
ELSE NULL
END)
LIKE
(CASE WHEN @YESNOActivity = 'Yes'
THEN '%,' + TblActivity.ActivityServActId + ',%'
ELSE 0
END)