我正在使用SQL Express Edition 2016
这是我的查询。它返回空值。
Declare @JSON varchar(max)
SELECT @JSON = BulkColumn
FROM OPENROWSET (BULK 'F:\JKPM\18Aug2018\Mod1.json', SINGLE_CLOB) as j
SELECT * FROM OPENJSON (@JSON)
WITH(transactionId nvarchar(50))
我的JSON是:
{
"data": {
"deviceTransactions": [{
"transactionId": "3f147089-ff52-5552-a29b-cd32a7e2ba97",
"organizationId": "9023179c-7888-4c5e-a831-28259b8a8872",
"device": "JTLSPERF1",
"event": "PUSH",
"siteName": "TEST-SITE",
"siteId": "5555f068-3ed2-4f83-b084-666f4f92734",
"createdTime": "Sat, 18 Aug 2018 13:51:57 GMT",
"updatedTime": "Sat, 18 Aug 2018 13:53:07 GMT",
"userName": "test1",
"userId": "test1",
"status": "Failed",
"details": {
"count": 251,
"deviceId": "44343570-7eb5-11e8-8160-057818f1057b",
"error": {
"errorMessage": "Failed to start polling status of the Queue",
"stage": "MANAGE_PUSH",
"errorCode": "ERR021001"
},
"jcigId": "4rtr5aa6a2-71b5-455f-8890-7e2aa398b757"
},
"cancelledBy": ""
}],
"libraryTransactions": []
},
"success": true,
"statusCode": 200
}
答案 0 :(得分:0)
transactionId是deviceTransactions的一部分,也是一个数组。这是在这种情况下如何使用openjson的示例:
this