title: Pivot/dynamic SQL help required
body: <p>I need to convert the following data (simplified for SO purposes):-</p>
  
  <pre><code>DataTitle   DataValue   Id
  ==============================
  Thing 1     Data 1      12345
  Thing 2     Data 2      12345
  Thing 3     Data 3      12345
  Thing 4     Data 4      12345
  Thing 1     Data 5      23456
  Thing 2     Data 6      23456
  Thing 3     Data 7      23456
  Thing 4     Data 8      23456
  </code></pre>
  
  <p>Into this:-</p>
  
  <pre><code>ID      Thing1    Thing2    Thing3    Thing4
  ==============================================
  12345   Data1     Data2     Data3     Data4
  23456   Data5     Data6     Data7     Data8
  </code></pre>
  
  <p>Basically need to group by the ID, and then for each 'Thing' I then need a column.   For the benefits of this example there will always be the same number of 'Things' in the table, so the numbers of columns isn't subject to change.  I can't change the starting table structure at this stage, so unfortunately the solutions can't be a rethink of the table design... </p>
  
  <p>I've looked at using PIVOT to solve this, but as I'm not aggregating the data I got really stuck..</p>
  
  <p>Is there some syntax to the PIVOT command that would help me achieve this, or do I need something more dynamic in nature.</p>
  
  <p>Thanks in advance</p>