title: How can I combine multiple rows into a comma-delimited list in SQL Server?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2046037/sql-server-can-i-comma-delimit-multiple-rows-into-one-column">SQL Server: Can I Comma Delimit Multiple Rows Into One Column?</a>  </p>
  </blockquote>
  
  
  
  <p>I have Table X(X_ID, X_Name) is 1-M with Table Y(Y_ID, Y_Value)</p>
  
  <p>Table X:</p>
  
  <pre><code>X_ID    X_Name
  ----    ------
  12      foo
  14      foo2
  16      foo3
  </code></pre>
  
  <p>Table Y:</p>
  
  <pre><code>X_ID    Y_Value
  ----    -------
  12      A
  12      B
  14      C
  14      D
  14      E
  16      F
  16      G
  </code></pre>
  
  <p>How to get the following result using T-Sql ?</p>
  
  <pre><code>X_ID   X_Name   Y_Value
  ----   ------   ------
  12     foo      A,B
  14     foo2     C,D,E
  16     foo3     F,G
  </code></pre>
  
  <p>Thanks</p>