In my SQL query I have a single value parameter @MandatoryGroup which is returning an integer value for one of the ID numbers for a list like this
202 Group A
203 Group B
204 Group C
205 Group D
So the value of @MandatoryGroup could be 202
In my table of people, people are linked to groups by a column containing a comma separated list e.g. if a person is in groups A, C and D the value in the column TblPeople.PeopleCourseGroup = 202,204,205
I'm trying to work out how to find all records which contain group 202. The closest I can get without errors is shown below but this only gives me results where people are ONLY in group 202. A record with the value 202,204,205 would not be found.
SELECT
TblPeople.PeopleId
,TblPeople.PeopleSurname
,TblPeople.PeopleForename
,TblPeople.PeopleCourseGroup
FROM
TblPeople
WHERE
CONVERT(Varchar(10),@MandatoryGroup) = TblPeople.PeopleCourseGroup
I've tried various combinations of IN and LIKE without success. web searches are bringing back lots of results about multi value parameters but I can't see anything relating to doing this the other way round.
Eils