I have JSON data type in one of the columns in table as:
{
"phones":[" 16024000022"]
}
I tried to use next in order to parse this column to be readable:
SELECT phones, m.phone_numbers
FROM [AuthX].dbo.migration m
CROSS APPLY OPENJSON( m.phone_numbers)
WITH (
phones NVARCHAR(50) '$'
)
But I am getting null values in new column phones.
CodePudding user response:
You can get a JSON array members in a form of key - value pairs. For example
SELECT id, [key], value
FROM
(values (1, '{"phones":[" 14809074223"," 16024000022"]}')
) m (id,phone_numbers )
CROSS apply OPENJSON(m.phone_numbers, '$.phones');
