title: how to pivot rows to columns
body: <p>Every example of using PIVOT in MSSQL shows people using this to aggregate data. I'm trying to exploit this to just simply transpose rows to columns</p>
  
  <p>For instance, consider the follwoing data</p>
  
  <pre><code>   SELECT 11826 ID,cast('64 ' as varchar(1000)) as answer,75098 QuestionID,2785 CollectionID  into #temp
  insert into #temp SELECT 11827 ID,cast('Security ' as varchar(1000)) as answer,75110 QuestionID,2785 CollectionID 
  insert into #temp SELECT 11828 ID,cast('42 ' as varchar(1000)) as answer,75115 QuestionID,2785 CollectionID 
  insert into #temp SELECT 11829 ID,cast('3/23/2010 12:01:00 AM ' as varchar(1000)) as answer,75119 QuestionID,2785 CollectionID 
  insert into #temp SELECT 11830 ID,cast('3/25/2010 ' as varchar(1000)) as answer,75120 QuestionID,2785 CollectionID 
  insert into #temp SELECT 11898 ID,cast('67 ' as varchar(1000)) as answer,75313 QuestionID,2792 CollectionID 
  insert into #temp SELECT 11899 ID,cast('True ' as varchar(1000)) as answer,75314 QuestionID,2792 CollectionID 
  insert into #temp SELECT 11900 ID,cast('0 ' as varchar(1000)) as answer,75315 QuestionID,2792 CollectionID 
  insert into #temp SELECT 11901 ID,cast('adlfkj@alkdfj.com ' as varchar(1000)) as answer,75316 QuestionID,2792 CollectionID
  </code></pre>
  
  <p>The results should yield something like</p>
  
  <pre><code>CollectionID   [AnswerFor75098]     [AnswerFor75110]     [AnswerFor75115]     [AnswerFor75315]...
  2785             64                  Security            42                   
  2792             Null               Null                 Null                  67
  </code></pre>
  
  <p>I've been experimenting with PIVOT however i'm not sure this is the correct solution. If so, does anybody have a hint i could use?
  I think i can probably do this in a stored procedure fairly however, i'm trying to avoid using cursors if possible.</p>
  
  <p>Thanks for the help</p>