SQL 来自单独 table (parseJSON) 的每条记录的递归评估

SQL Recursive evaluation for each record from separate table (parseJSON)

我正在尝试为每条记录评估 SQL 中的 JSON 响应,并将它们合并为一个 table。

我目前正在使用 consuming-json-strings-in-sql-server/ 来解析 json 其中 returns 一个 table 值函数, 例如

select *
from parseJSON('{"a":1}'); 

这给出

element_id sequenceNo  parent_ID   Object_ID   NAME    StringValue ValueType
    1           0           1       NULL        a                       int
    2           1           NULL    1           -                       object

这需要在每个记录上递归并合并存储在另一个 table 中的每个 JSON 字符串。我敢肯定我又想多了,希望能有一些简单的东西...

一如既往,非常感谢您的帮助!

我想你想要的是这个:

select t.*,j.* from yourtable t cross apply parseJSON(t.jsonColumn) j

是否要加入 json 返回的 属性 和 table 的列?

select * from table1 t inner join 
(select * from parseJSON('{"a":1}') where Name = 'a') p
ON t.a = p.Name