I have a column myColumn
in myTable
table with this value:
"6285":[
{
"75963":{"lookupId":"54","value":"0","version":null},
"75742":{"lookupId":"254","value":"991","version":null}
}
]
I need to write select
query using JSON_VALUE
or JSON_QUERY
functions (my sql server
version does not support OPENJSON
). The query should return this result:
"75963-0, 75742-991"
As you can see I need values of value
parameter. Also note that I don't know what elements will an object inside 6285
array contain. I mean I wouldn't know in advance that there will be 2 elements (75963 and 75742) in it. There could be more or less elements and they could be different of course. However there will always be only one object in 6285
array.
What kind of select
can I write to achieve it?
JSON_QUERY()
, you should be able to useOPENJSON()
.Microsoft SQL Server 2017 (RTM) - 14.0.1000.169 (X64) Aug 22 2017 17:04:49 Copyright (C) 2017 Microsoft Corporation Developer Edition (64-bit) on Windows Server 2012 R2 Standard 6.3 <X64> (Build 9600: ) (Hypervisor)
. Maybe it is possible to useOPENJSON
in sql editor, but I am querying usingHibernate
(Java framework) and it does not supportOPENJSON
I think. But If you could write a query usingOPENJSON
it would also help.