It is probably something stupid what I did not see, but I can't manage to get JSON_VALUE or JSON_QUERY to work as I expect how it should work:
DECLARE @json nvarchar(max) = N'{"1031":"test-de","1033":"test-en","1036":"test-fr"}'
SELECT *
FROM OPENJSON(@json)
returns correct 3 rows.
DECLARE @json nvarchar(max) = N'{"1031":"test-de","1033":"test-en","1036":"test-fr"}'
SELECT ISJSON(@json) is_json
, JSON_VALUE(@json, '$') label
, JSON_QUERY(@json, '$') label2
returns 1 row, but label is NULL and label2 shows the whole string. OK, but:
DECLARE @json nvarchar(max) = N'{"1031":"test-de","1033":"test-en","1036":"test-fr"}'
SELECT ISJSON(@json) is_json
, JSON_VALUE(@json, '$.1031') label
, JSON_QUERY(@json, '$.1033') label2
returns 0 rows.
EDIT
I did expect to get results like this:
is_json, label, label2
1, test-de, test-en