title: T-SQL Group Rows Into Columns
body: <p>How can I group an (unknown) number of rows into a single row where the set columns determine the grouping?</p>
  
  <p>For example, shift</p>
  
  <pre><code>Ref      Name            Link
  ==============================
  1        John            L1
  1        John            L2
  1        John            L8
  2        Steve           L1
  2        Steve           L234
  </code></pre>
  
  <p>Into</p>
  
  <pre><code>Ref      Name            ...    ...    ...
  ==========================================
  1        John            L1     L2     L8
  2        Steve           L1     L234   NULL
  </code></pre>
  
  <p>Thanks for any help</p>