title: T-SQL String Concatenating multiple rows
body: <blockquote>
    <p><strong>Possible Duplicates:</strong><br>
    <a href="https://stackoverflow.com/questions/451415/simulating-group-concat-mysql-function-in-ms-sql-server-2005">Simulating group_concat MySQL function in MS SQL Server 2005?</a><br>
    <a href="https://stackoverflow.com/questions/6603319/concatenate-values-based-on-id">Concatenate values based on ID</a>  </p>
  </blockquote>
  
  
  
  <p>I am trying to write a SQL query in SSMS 2008 to group by a single column.  I have a table with just two columns: Part Number and Product Code.  Both of these columns are VARCHAR data types.</p>
  
  <p>Right now my table looks something like:</p>
  
  <pre><code>Part Number              Product Code
  111222                   AAAAA
  111222                   BBBBB
  111222                   CCCCC
  111223                   AAAAA
  111224                   AAAAA
  111225                   AAAAA
  111226                   DDDDD
  111226                   EEEEE
  </code></pre>
  
  <p>But I want this table to instead look like:</p>
  
  <pre><code>111222                   AAAAA, BBBBB, CCCCC                 
  111223                   AAAAA
  111224                   AAAAA
  111225                   AAAAA
  111226                   DDDDD, EEEEE                   
  </code></pre>
  
  <p>How do I do this? I have read some websites recommending coalesce function, but I can't seem to figure out a way to get this to work correctly.</p>