I am using SQL Server 2008 and inherited a database that did not use many to many. They instead used a comma-separated column. I have found how to link the comma-separated values to the name of the program. But I need a list of the programs and the offices they belong to, like this
OFFICE table:
ID  Name
--- ------
1   HQ
2   PA
3   CEO
PRG table:
ID  Name    Office Affected
--  ----    ---------------
A   PRG1    1,3
B   PRG2    2
C   PRG3    2,3
D   PRG4    1,2
Output that I need :
Name    Programs
----    ---------
HQ      PRG1, PRG4
PA      PRG2, PRG3, PRG4
CEO     PRG1, PRG3
 
     
    