Below example converts rows to columns using UNPIVOT clause.
Assuming you have a table like this:
And you want to convert like this:
Use the query:
SELECT
ID, col, val
FROM
Table_1
UNPIVOT
(val for col in (col1, col2, col3)) p
You can also apply WHERE clause like this:
SELECT
ID, col, val
FROM
Table_1
UNPIVOT
(val for col in (col1, col2, col3)) p
WHERE id=1
Result: