没有名称的TSQL JSON_值数组

没有名称的TSQL JSON_值数组,json,tsql,Json,Tsql,试图在MS SQL 2016中实现以下功能,但需要MS SQL JSON专家的帮助 我有一个文本字符串中包含JSON的表 [ { "static-list-id": 37, "internal-list-id": 41, "timestamp": 1554831874747, "vid": 9350104, "is-member": true }, { "static-list-id": 39, "internal-list

试图在MS SQL 2016中实现以下功能,但需要MS SQL JSON专家的帮助

我有一个文本字符串中包含JSON的表

  [
  {
    "static-list-id": 37,
    "internal-list-id": 41,
    "timestamp": 1554831874747,
    "vid": 9350104,
    "is-member": true
  },
  {
    "static-list-id": 39,
    "internal-list-id": 43,
    "timestamp": 1554831874931,
    "vid": 9350104,
    "is-member": true
  }
  ]'
这是我的SQL语句,我想我可能需要一个JSON_查询

SELECT 
    JSON_VALUE([MyNVarCharWithJSONColumn],'strict $."static-list-id"') AS static_list_id
FROM
  [MyTable] C
  WHERE ISJSON([MyNVarCharWithJSONColumn])>0
这些是我希望从SQL语句中得到的结果,每行一个

static\u list\u id
--------------
37
39
非常感谢您的帮助

您可以使用:

SELECT a.static_list_id
FROM MyTable 
CROSS APPLY OPENJSON(MyNVarCharWithJSONColumn)
WITH (static_list_id INT N'$."static-list-id"') AS a;

您可以使用:

SELECT a.static_list_id
FROM MyTable 
CROSS APPLY OPENJSON(MyNVarCharWithJSONColumn)
WITH (static_list_id INT N'$."static-list-id"') AS a;

这是我要的,谢谢。如何将JSON中的另一列添加到列表中?@Simon,您可以将所有需要的列放在WITH子句中(逗号分隔)。这就是我要的,谢谢。如何将JSON中的另一列添加到列表中?@Simon,您可以将所有需要的列放在WITH子句中(逗号分隔)。