So I have a table that has a column for Name
, and a column for Value
and an ID
. There can be multiple rows for the same ID
. I would like to create a select that will return a single row for each ID and the values in the Name
column would be the column name, and the Value
would be the value. Example:
CREATE TABLE dbo.Attribute
(
AttributeID int NOT NULL,
Name varchar(20) NOT NULL,
Value varchar(20) NOT NULL
) ;
Data:
{1,"Color", "Blue"},{1,"Material", "leather"}
Would like Select to return:
[AttributeID:1, Color:Blue, Material: leather]
I have been playing with PIVOT
and UNPIVOT
but not getting what I need.