title: Pivoting data using SQL 2008
body: <p>I'm having some trouble with the syntax on this.</p>
  
  <pre><code>SELECT a.[Id]
    ,a.[Ext]
    ,a.[Title]
    ,b.Text
    FROM [Sliders] a
    LEFT OUTER JOIN SliderItems b on b.SliderId = a.Id
  </code></pre>
  
  <p>That returns a dataset like this:</p>
  
  <pre><code>Id                                    Ext   Title       Text
  1140E5F9-7ABB-42D6-B054-9D30461FC4A9 .jpg Test me big asdftyrthg
  1140E5F9-7ABB-42D6-B054-9D30461FC4A9 .jpg Test me big asdfd22sdf
  1140E5F9-7ABB-42D6-B054-9D30461FC4A9 .jpg Test me big asdf342324543
  1140E5F9-7ABB-42D6-B054-9D30461FC4A9 .jpg Test me big asdf;l;po09
  </code></pre>
  
  <p>What I really need to do is pivot the data out so that the different text items are each in their own column.</p>
  
  <p>Thanks.</p>
  
  <p>Edit: I think this is closer, but it is telling me the column ID is specified multiple times, can't get rid of that one.</p>
  
  <pre><code>SELECT *
  FROM
  (SELECT Id, Title FROM Sliders)AS a
  LEFT JOIN SliderItems s on (s.SliderId = a.Id)
  PIVOT
  (
    MAX(s.Text)
  FOR s.Text IN ([One],[Two],[Three],[Four])
  ) AS p
  </code></pre>