ArtOx
ArtOx

Reputation: 11

SQL Table Row Convert to List of Columns

What is the best way to convert a row with columns to a list with rows? In the list, I need one column with the old column name and one column with the old column value.

For Example:

Current:

PersonId | PersonFirstName | PersonLastName |

Need:

ColumnName | ColumnValue

Hope this makes sense. Thanks for any help.

Upvotes: 1

Views: 1571

Answers (1)

Andrew Bezzub
Andrew Bezzub

Reputation: 16032

You need to use Pivot clause. You can see this question for some examples.

Upvotes: 4

Related Questions