I am trying to update a table from a JSON object. The table has a structure like
In this table, each quote would be the new single row with the quote key as the value for the column ABBR.
Based on the examples I found, I was able to do below, but now I am stuck on how to update the table there. It creates a new column for each quote key.
DECLARE @fx_rates_json NVARCHAR(MAX)
SET @fx_rates_json = N'{
"date": "2019-12-02",
"quotes": {
"USDARS": 3.673197,
"USDAUD": 78.79768,
"USDBGN": 110.795056
}
}'
SELECT jsonpayload.*
FROM OPENJSON (@fx_rates_json, N'$')
WITH (
Date DATETIME N'$.date',
ARS float N'$.quotes.USDARS',
AUD float N'$.quotes.USDAUD',
BGN float N'$.quotes.USDBGN'
) AS jsonpayload
