title: Using MS SQL Server 2005, how can I consolidate detail records into a single comma separated list
body: <p><strong>BACKGROUND:**I am running **MS2005</strong>.  I have a MASTER table (ID, MDESC) and a DETAIL table (MID, DID, DDESC) with data as follows</p>
  
  <pre><code>1 MASTER_1
  2 MASTER_2
  1 L1 DETAIL_M1_L1
  1 L2 DETAIL_M1_L2
  1 L3 DETAIL_M1_L3
  2 L1 DETAIL_M2_L1
  2 L2 DETAIL_M2_L2
  </code></pre>
  
  <p>If I join the tables with </p>
  
  <pre><code>SELECT M.*, D.DID FROM MASTER M INNER JOIN DETAIL D on M.ID = D.MID
  </code></pre>
  
  <p>I get a list like the following:</p>
  
  <pre><code>1 MASTER_1 L1
  1 MASTER_1 L2
  1 MASTER_1 L3
  2 MASTER_2 L1
  2 MASTER_2 L2
  </code></pre>
  
  <p><strong>QUESTION:</strong>  Is there any way to use a MS SQL select statement to get the detail records into a comma separated list like this:</p>
  
  <pre><code>1 MASTER_1 "L1, L2, L3"
  2 MASTER_2 "L1, L2"
  </code></pre>