title: Taking duplicate lines and squeezing them into 1 row on SQL Server 2008 R2?
body: <p>I'm trying to write a stored procedure in SQL Server that will eliminate some logic in my C# program. What I'm doing right now is the query is in a view. Then I'm making a list with the view.</p>
  
  <pre><code>List&lt;MyView&gt; listOrdered = new List&lt;MyView&gt;();
  </code></pre>
  
  <p>Here's where it gets hairy. The query returns rows that are duplicates. I don't want to delete the duplicate rows I want to combine them into 1 row. The rows are identical except for 1 column.</p>
  
  <p>Example:</p>
  
  <pre><code>UID     Name     Age    Child
  1       John     50     Sally
  1       John     50     Steve
  2       Joseph   42     Timmy
  2       Joseph   42     Billy
  </code></pre>
  
  <p>So what I'm doing in C# is writing logic that says: (pseudo code)</p>
  
  <pre><code>foreach(item in list)
  {
        if (UID != UIDCurrent)
        { 
            Build Row
            AppendRow to list
        }
        else
        {
            Append Child Column to Current Child Column
         }
  }
  </code></pre>
  
  <p>Basically it gives me:</p>
  
  <pre><code>UID     Name     Age   Children
  1       John     50    Sally, Steve
  </code></pre>
  
  <p>But instead of doing this logic in C# I would like to do this a stored procedure. So how I can I get SQL Server to combine the children column for each row instead of multiple rows. </p>
  
  <p>If you need anything else to help you help me I will respond. </p>
  
  <p>Oh guys believe me I don't want to do it this way either. The Database I'm using is huge and complex and doing this with C# was sensible and works but I've been asked to turn my function that does this in C# into a stored procedure. I just want to see if this is even possible.</p>