Open this example in the interactive library
Source code
WITH input(doc) AS (VALUES('{"oldCode":"P2","qty":3}')) SELECT json_remove(json_set(doc,'$.sku',json_extract(doc,'$.oldCode')),'$.oldCode') AS updated FROM input;
Sample output
[
{
"updated": "{\"qty\":3,\"sku\":\"P2\"}"
}
]