Please forgive the title, I wasn't sure how exactly to describe the situation below...
I have 2 tables. One column in the first table has a set of comma delimited codes that are in a second table. So, the two tables look like this:
Table1
RepID | RepDate | RepLocation
1 1/1/2010 BH,,,,AH,,,
2 2/1/2010 ,,,,,AH,,,
Table2
LocID | LocName
BH Bliss Hall
AH Agans Hall
I can successfully select from both tables using joins, and I obviously get multiple rows in the resultset:
RepID | RepDate | RepLocation
1 1/1/2010 Bliss Hall
1 1/1/2010 Agans Hall
2 2/1/2010 Agans Hall
But what I'd really like to do is get a result that looks like this:
RepID | RepDate | AllRepLocations
1 1/1/2010 Bliss Hall Agans Hall
2 2/1/2010 Agans Hall
I've never tried to do this before, and I'm having trouble coming up with the T-SQL to get this result, if it is even possible. I am calling a stored procedure, so if I need to do some extra coding or machinations to get the result I want, it is not a problem as I can do them in the stored procedure. This is on SQL Server 2008 R2.
Thank you.