在TSQL中将JSON转换为XML?

时间:2021-10-10 22:17:48

I have a development to execute dinamyc queries stored at column table, all was programmed to manipulating parameters in XML, but there is some other apps that send the parameters in a json, so I would like to know if some one have made something to convert a Json to XML in T-SQL

我有开发执行dinamyc查询存储在列的表,所有在XML编程操作参数,但有一些其他应用程序发送一个json的参数,所以我想知道如果有人已经在t - sql将json转换成XML

2 个解决方案

#1


2  

Just to update this, You can now use OPENJSON to convert to a table and then translate the result to a XML document.

为了更新这个,您现在可以使用OPENJSON转换到一个表,然后将结果转换为XML文档。

https://docs.microsoft.com/en-us/sql/relational-databases/json/convert-json-data-to-rows-and-columns-with-openjson-sql-server

https://docs.microsoft.com/en-us/sql/relational-databases/json/convert-json-data-to-rows-and-columns-with-openjson-sql-server

SELECT * 
FROM  OPENJSON('{"title": "Sample Konfabulator Widget","name": "main_window" }') as DATA
FOR XML RAW, ELEMENTS

#2


3  

This function works for my tasks: http://sqlsunday.com/2013/05/12/converting-json-data-to-xml-using-a-t-sql-function/

这个函数适用于我的任务:http://sqlsunday.com/2013/05/12/converting-json-data-to-xml- use -a-t-sql-function/

#1


2  

Just to update this, You can now use OPENJSON to convert to a table and then translate the result to a XML document.

为了更新这个,您现在可以使用OPENJSON转换到一个表,然后将结果转换为XML文档。

https://docs.microsoft.com/en-us/sql/relational-databases/json/convert-json-data-to-rows-and-columns-with-openjson-sql-server

https://docs.microsoft.com/en-us/sql/relational-databases/json/convert-json-data-to-rows-and-columns-with-openjson-sql-server

SELECT * 
FROM  OPENJSON('{"title": "Sample Konfabulator Widget","name": "main_window" }') as DATA
FOR XML RAW, ELEMENTS

#2


3  

This function works for my tasks: http://sqlsunday.com/2013/05/12/converting-json-data-to-xml-using-a-t-sql-function/

这个函数适用于我的任务:http://sqlsunday.com/2013/05/12/converting-json-data-to-xml- use -a-t-sql-function/