Hi,I'm refining a search query and opted to move towards a dynamic sql approach. I'm having trouble converting some areas of the SPROC. cad = table with just userID that I am joining the Athletic table onto.Original(@athids is null or exists(select athID from Athletic aa where aa.userID = cad.userID and aa.rating >= isNull(@aSkillRating,rating) and ',' + @athids + ',' like '%' + cast(aa.athID as varchar(3)) + ',%'))
My attempt at converting it which doesn't work. SET @SQL = @SQL + CASE WHEN @athIDs IS NOT NULLTHEN ' AND Exists(select athID FROM Athletic aat WHERE aat.userID = d.userID and aat.rating >= isNull(' + @aSkillRating + ',rating) AND athleticIDS like '% cast(athID as varchar(3)) + '%')ELSE '' END I'm passing a comma delimited list of athIDs as well as a rating id. So each of those athids must satisfy the minimum rating criteria.I hope this is enough information.thank you. quote: