sql server - json sql with list items -


i have json stored in sql2016. when run query parts of json returns value , other parts don't return value. here json stored in table dbo.trades datatype follows

create table [dbo].[trades]( [_id] [int] identity(1,1) not null, [trade] [nvarchar](max) null, 

my json formatted below , stored in trade column

{   "direction": "short",   "powerbars": 2,   "powerbarstime": [     "2016-11-10t20:25:32.481424-05:00",     "2016-11-10t20:44:01.8993031-05:00"   ] } 

since powerbarstime list in json, have provide index print it. don't know how many entries eb there in list. there way merge list part of json , return comma delimited column?

i have print

select        _id,  json_value(trade, '$.powerbars') powerbars, json_value(trade, '$.powerbarstime[0]') powerbarstime1, json_value(trade, '$.powerbarstime[1]') powerbarstime2            dbo.trades order _id desc 

i 2 items on list hardcode sql.

results

how can merge list items under json_value(trade, '$.powerbarstime') can see 1 comma delimited column.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -