'Concatenate Column and value as property To existing JSON object in another column In SQL Server

Let's say I have the following table Product

enter image description here



Solution 1:[1]

You can use a nested FOR JSON subquery, which breaks open the original JSON using OPENJSON and re-aggregates it

SELECT
  p.ProductID,
  p.ProductName,
  (
      SELECT
        p.ProductID,
        p.ProductName,
        j.Price,
        j.Shipper
      FROM OPENJSON(p.Results, '$.Results')
        WITH (
            Price int,
            Shipper varchar(100)
        ) j
      FOR JSON PATH, ROOT('Results')
  ) AS Results
FROM Product p;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Charlieface