Accessing JSON Array using JSON_VALUE

65 Views Asked by At

I have a table (Deltails) with two columns (Id+ Result) in SQL Server database, where Id is the primary key and Result contains JSON object.

This Result column

[{"ID":"2023","Answer":"False","Reason":"Need attachment"}]
[{"ID":"1005","Answer":"TRUE","Reason":""}]
[{"ID":"1879","Answer":"TRUE","Reason":""}]

I'm trying to get from table Deltails, column Result, value Answer only. For that, I wrote the following SQL query but I didn't get the result. Does anyone have an idea about to get JSON object value as the normal column value as a query result.

SELECT
    JSON_VALUE(X.value, '$.Answer') AS Name 
FROM Deltails
CROSS APPLY OPENJSON(Result) X

Thank you

0

There are 0 best solutions below