I have JSon data on an Sql server.
{
"PartnerName": null,
"PartnerCurrencyCode": "UAD",
"PricingConditions": [
{
"PricingConditionId": 659853,
"ConditionTypeCode": "ABCD",
"ConcessionItemTypeCode": "ABC",
"PriceLevel": null
}
],
"CurrencyMultiplier": 0
}
Expected results:
PartnerName PartnerCode PartnerCurrencyCode PricingConditionId
NULL NULL UAD 659853
I read that Sql Server 2016 has the ability to read JSON data and handle the following requests.
Request 1:
SELECT * FROM OPENJSON(@json, '$')
Request 2:
SELECT *
FROM OPENJSON(@json)
WITH (PartnerName NVARCHAR(50) '$.PartnerName',
PartnerCode nvarchar(50) '$.PartnerCode',
PartnerCurrencyCode nvarchar(50) '$.PartnerCurrencyCode',
PricingConditionId nvarchar(50) '$.PricingConditions.PricingConditionId')
Query Results 2:
PartnerName PartnerCode PartnerCurrencyCode PricingConditionId
NULL NULL UAD NULL
I expected the value of "PricingConditionId" - 659853
source
share