title: How to combine multiple rows in MSSQL
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/941103/concat-groups-in-sql-server">Concat groups in SQL Server</a>  </p>
  </blockquote>
  
  
  
  <p>I am trying to write an SQL query that will combine rows together. I need it to group together an unspecified number of rows by ID# but concatenate their addresses let's say into one cell.</p>
  
  <p>Say we have</p>
  
  <pre><code>ID, Address
  p1 a1
  p1 a2
  p1 a3
  p2 a4
  p2 a5
  </code></pre>
  
  <p>I want to get </p>
  
  <pre><code>ID, Address
  p1 a1,a2,a3
  p2 a4,a5
  </code></pre>
  
  <p>The number of addresses per ID can vary. Some IDs have 1, others can have 50.</p>
  
  <p>Any help would be appreciated. Thanks in advance!</p>