2017-06-22 82 views
1

我正在使用sqlserver 2012.我的表(綁定)包含以下數據。解析sql服務器中的Json值

e_id  f_id  value 

1001  1   [{"id":85574},{"id":169794},{"id":151336}]') 
1002  1   [{"id":85574},{"id":169794}]') 

i want to select e_id and value(parsed value) from the above table. 

Sample output. 

e_id   value 

1001   85574 
1001   169794 
1001   151336 
1002   85574 
1002   16974 

我試圖使用在 ​​

select StringValue from parsejson('[{"id":85574},{"id":169794},{"id":151336}]')->This query Returns result. 

select e_id,(Select stringvalue from parseJSON(v1.value)) from bindings v1 where v1.value<>'' and v1.f_id=1 

showing error message Subquery returned more than 1 value" 

Below query also. 

select (select stringvalue from parseJSON(v1.value)) from bindings v1 where f_id=1 

無法從表解析值發現parsejson功能(用戶定義的功能)。

回答

0

我認爲你必須在c#中先解析服務器端的這個json,然後在數據庫中只插入值部分。