title: Concatenate many rows into a single text string
body: <p>I'm trying to concatenate several names into a single column but I'm having trouble getting there.</p>
  
  <pre>
  DECLARE @Names VARCHAR(8000) 
  
  SELECT 
      p.Pato_Id
      @Names = COALESCE(@Names + ', ', '') + e.First_Name + ' ' + e.Last_Name
  
  FROM 
      Patos p
  
  LEFT JOIN 
      Pato_Owners po
  ON
      po.Pato_Id = p.Pato_Id
  LEFT JOIN 
      Person e
  ON
      po.Owner_Id = e.Person_Id
  </pre>
  
  <p>How can this be done?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>When I'm making a normal select I getting</p>
  
  <pre>
  PatoID First  Last 
  0      John   Wort
  0      Dan    Mass
  1      Till   Bos
  2      Wrap   Sim
  2      Port   Lock
  </pre>
  
  <p>And what I want is:</p>
  
  <pre>
  PatoID Names
  0      John Wort, Dan Mass
  1      Till Bos
  2      Wrap Sim, Port Lock
  
  </pre>