鉴于:
SELECT * FROM OPENJSON(JSON_QUERY('[{"JobId":"2838","Options":1}, {"JobId":"2839","Options":1}]'))
给我们:
key value type
0 {"JobId":"2838","Options":1} 5
1 {"JobId":"2839","Options":1} 5
如何更改查询以返回工作ID?
value
2838
2839
答案 0 :(得分:3)
这应该做
SELECT JobId
FROM OPENJSON('[{"JobId":"2838","Options":1}, {"JobId":"2839","Options":1}]')
WITH (JobId INT N'$.JobId');