title: How do I PIVOT in SQL Server with dynamic columns, values, and datatypes?
body: <p>I have a table that stores the data as follows:</p>
  
  <pre>
  ID       ListId   ModuleId  RecordId    NValue    CValue  LValue  Caption  RowId
  8cb5f604 c07cea6f 24cb218c  _01F15T1LJ  2.00000           False   Wire #   24cb218c
  c023fe9e 2dcd56fe 24cb218c  _01F15T1LJ            Red     False   Label    24cb218c
  4a74bd46 c07cea6f 24cb218c  _01F15T1LJ  1.00000           False   Wire #   24cb218d
  30cae2cf 2dcd56fe 24cb218c  _01F15T1LJ            White   False   Label    24cb218d</pre>
  
  <p>I need to pivot the date on the RowId and display the results something like this:</p>
  
  <pre>
  RowId     Wire #   Label
  24cb218d  1.00000  White
  24cb218c  2.00000  Red
  </pre>
  
  <p>I cannot figure out how to force PIVOT to work in this way.</p>
  
  <p>The data in the tables, number of columns, and order are all open for editing by the end user. &nbsp;Is it possible to do this efficiently? &nbsp;If so, how.</p>