title: Denormalize into pipe separated list
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/6899/is-there-a-way-to-create-a-sql-server-function-to-join-multiple-rows-from-a-su">Is there a way to create a SQL Server function to &ldquo;join&rdquo; multiple rows from a subquery into a single delimited field?</a>  </p>
  </blockquote>
  
  
  
  <p>I have a tablle like this:</p>
  
  <pre>
  cust   acc
  -----------
  a      1
  b      2
  b      3
  c      4
  c      5
  c      6
  </pre>
  
  <p>I want to denormalize above into the following form</p>
  
  <pre>
  cust    acc
  ---------------
  a       1
  b       2|3
  c       4|5|6
  </pre>
  
  <p>please note that the acc column should now contain a pipe delimited list of accounts for any customer. Also the possible number of accounts for a customer can be variable.</p>
  
  <p>how to do this using SQL ?</p>