我目前有一个结构如下的表:
customer_id name phoneNumbers
1 Adam [{'type':'home','number':'687-5309'} , {'type':'cell','number':'123-4567'}]
2 Bill [{'type':'home','number':'987-6543'}]
将 phoneNumbers 列设置为 JSON 列类型。为简单起见,尽管我想将所有 JSON 电话号码转换为一个新的单独表。就像是:
phone_id customer_id type number
1 1 home 687-5309
2 1 cell 123-4567
3 2 home 987-6543
似乎它应该可以使用 OPENJSON,但到目前为止,我还没有弄清楚如何正确声明它的运气。任何帮助表示赞赏。