SQL Convert one column with distinct values into several columns

Viewed 1179

I´using SQL Server and I don´t know how to approach this issue. I have one table with 5.5M of records in the following form:

Device        Time             ValueID   Value   Voltage
------------------------------------------------------------
1   2014-03-08 22:50:00      AH1      90,0    90,000"

1   2014-03-08 22:50:00      AT1      5,5     5,500"

1   2014-03-08 22:50:00      PP1      0,0     0,000"

1   2014-03-08 22:50:00      WS1      0,0     0,000"

1   2014-03-08 22:50:00      WD1      270,0   270,000"

1   2014-03-08 22:50:00      SR1      0,0     0,000"

1   2014-03-08 23:49:00      ST1      8,288   2,993"

The column ValueID has 13 different datatypes and the column Value contains the measurement of the data type.

I need to create a table with the following form:

Device Time ValueID(AH1) ValueID(AT1) ValueID(PP1) etc...
------------------------------------------------------------
  1    xxxx   Value         Value          Value  

I was trying to use INSERT in a new table with case statement but it does not work, ¿any different aproach? ¿Any clue? Thanks

2 Answers
Related