title: MS SQL Server. Transpose columns of data to rows of data
body: <p>I have a Details table which can be described by the following:</p>
  
  <pre><code>Create table #Details (
  Id int identity,
  HeaderId int,
  ChannelId int,
  Value float
  )
  </code></pre>
  
  <p>We insert some seed data:</p>
  
  <pre><code>insert into #Details (HeaderId, ChannelId, Value) values(1, 0, 1019.51)
  insert into #Details (HeaderId, ChannelId, Value) values(1, 1, 20.1)
  insert into #Details (HeaderId, ChannelId, Value) values(1, 2, 21.2)
  insert into #Details (HeaderId, ChannelId, Value) values(1, 3, 22.3)
  insert into #Details (HeaderId, ChannelId, Value) values(1, 4, 23.4)
  
  insert into #Details (HeaderId, ChannelId, Value) values(2, 0, 1020.62)
  insert into #Details (HeaderId, ChannelId, Value) values(2, 1, 26.1)
  insert into #Details (HeaderId, ChannelId, Value) values(2, 2, 27.2)
  insert into #Details (HeaderId, ChannelId, Value) values(2, 3, 28.3)
  insert into #Details (HeaderId, ChannelId, Value) values(2, 4, 29.4)
  </code></pre>
  
  <p>Select All produces the following:</p>
  
  <p><a href="https://i.stack.imgur.com/B4FhC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B4FhC.png" alt="enter image description here"></a></p>
  
  <p>I would like to transpose the column data to rows, to produce the output below:</p>
  
  <p><a href="https://i.stack.imgur.com/soO3z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/soO3z.png" alt="enter image description here"></a></p>
  
  <p>Thanks in advance.</p>