-- create a table
CREATE TABLE TBL (
prodID NVARCHAR(6), fieldName NVARCHAR(20), fieldValue NVARCHAR(20)
);
-- insert some values
INSERT INTO TBL (prodId, fieldName, fieldValue) VALUES
('ABC123', 'name' , 'widget1'),
('ABC123', 'description' , 'Great widget!'),
('ABC123', 'status' , 'reserved'),
('XYZ999', 'name' , 'widget9'),
('XYZ999', 'description' , 'Lovely widget!'),
('XYZ999', 'status' , 'active');
-- fetch some values
SELECT
prodId,
name,
description,
status,
'2022-10-27' AS createdDate
FROM tbl
PIVOT (
MAX(fieldValue)
FOR fieldName IN (['name'], ['description'], ['status'])
) AS PivotTable
;
To embed this project on your website, copy the following code and paste it into your website's HTML: