[英]Json to temp table in sql server?
I want to convert below JSON to SQL #temp table. 我想将以下JSON转换为SQL #temp表。
{
"Person":
{
"Name": "John",
"age": 25,
"Address":
{
"streetAddress":"21 2nd St New York",
"postal":"10021"
},
"Numbers":
{
"home":"212 555-1234",
"fax":"646 555-4567"
}
}
}
Output: 输出:
+-------------+------------+------------------------------+-----------------------+---------------------+--------------------+
| Person/Name | Person/age | Person/Address/streetAddress | Person/Address/postal | Person/Numbers/home | Person/Numbers/fax |
+-------------+------------+------------------------------+-----------------------+---------------------+--------------------+
| John | 25 | 21 2nd St New York | 10021 | 212 555-1234 | 646 555-4567 |
+-------------+------------+------------------------------+-----------------------+---------------------+--------------------+
Questions: 问题:
Is there any build-in function to do this work ? 有任何内置功能可以完成这项工作吗?
Is there any per-defined CLR available ? 是否有任何按定义的CLR可用?
Can we do this with a table valued function ? 我们可以使用表值函数来做到这一点吗?
Currently I'm using this online Converter to convert as CSV then uploading it to Database.
目前,我正在使用此在线Converter将其转换为CSV,然后将其上传到数据库。 This one works fine till now , But i need to save time by directly uploading to database.
到现在为止,这一功能还不错,但是我需要通过直接上传到数据库来节省时间。
for this problem i haved use this solution. 对于这个问题,我不得不使用此解决方案。 IMHO i think is the best solution for the version of SQL SERVER before the 2016.
恕我直言,我认为这是2016年之前SQL SERVER版本的最佳解决方案。
i don't post you the code, because is little bit long. 我没有发布代码,因为它有点长。
I post you the link of the function, the example and the discussion about it. 我向您发布了函数链接,示例以及有关它的讨论。
Consuming JSON Strings in SQL Server by Phil Factor 通过Phil Factor在SQL Server中使用JSON字符串
I hope this is hopefully for you. 我希望这对你有希望。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.