This is my code to do part of what I want to do:
SELECT uID, ColumnName, ColumnResult
FROM table
UNPIVOT
(
ColumnResult
for ColumnName in (COL1,COL2,COL3)
)u
This returns something like this:
Thanks
You can use the following query which replaces the column name with the new value:
select uID,
case ColumnName
when 'COL1' then 'columnOne'
when 'COL2' then 'columnTwo'
when 'COL3' then 'columnThree'
end ColumnName,
ColumnResult
from TABLE
unpivot
(
ColumnResult
for ColumnName in (COL1,COL2,COL3)
)u;