我已将一些数据作为 JSON 字符串存储在表中,如下所示。
[
{
"firstName":"John",
"lastName":"Smith",
"age":25,
"Address":{
"streetAddress":"21 2nd Street",
"city":"New York",
"state":"NY",
"postalCode":"10021"
},
"PhoneNumbers":{
"home":"212 555-1234",
"fax":"646 555-4567"
}
},
{
"firstName":"Mike",
"lastName":"Lee",
"age":30,
"Address":{
"streetAddress":"10 Street",
"city":"New York",
"state":"NY",
"postalCode":"10021"
},
"PhoneNumbers":{
"home":"212 555-3265",
"fax":""
}
}
]
要将这些数据导出到 excel 文件,我需要进行查询以获取这些详细信息,如下所示
使用 CROSS APPLY OPENJSON 我可以获取姓名和年龄,但如何获取地址和联系方式作为列?