title: SQL Server : Transpose rows to columns
body: <p>Apart from writing the cursor reading each rows and populating it into columns, any other alternative if I need to transpose each rows into columns ?</p>
  
  <pre><code>TimeSeconds TagID Value
  1378700244  A1    3.75
  1378700245  A1    30
  1378700304  A1    1.2
  1378700305  A2    56
  1378700344  A2    11
  1378700345  A3    0.53
  1378700364  A1    4
  1378700365  A1    14.5
  1378700384  A1    144
  1378700384  A4    10
  </code></pre>
  
  <p>The number of columns are not fixed.</p>
  
  <p>Output : I just assigned n/a as a placeholder for no data in that intersection.</p>
  
  <pre><code>TimeSec     A1    A2    A3    A4
  1378700244  3.75  n/a   n/a   n/a
  1378700245  30    n/a   n/a   n/a
  1378700304  1.2   n/a   n/a   n/a
  1378700305  n/a   56    n/a   n/a
  1378700344  n/a   11    n/a   n/a
  1378700345  n/a   n/a   0.53  n/a
  1378700364  n/a   n/a   n/a   4
  1378700365  14.5  n/a   n/a   n/a
  1378700384  144   n/a   n/a   10
  </code></pre>
  
  <p>Hope you can share with me some tips. Thanks.</p>