In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to export the data in SQL Server to XML and Json. I hope you will get something after reading this article. Let's discuss it together.
Data export to XML
After SQL Server 2005, a for xml clause is provided to natively support XML in relational databases. With this command, the result set of 2D relationships can be converted to XML, and the data can be saved as XML through BCP.
For example, the following data:
We can export it to a XML file with the following BCP command (note that there is no enter) and save it:
BCP "SELECT TOP 30 [bom_no], [LEVEL] FROM [sqladmin]. [dbo]. [bom] FOR XML path,TYPE, ELEMENTS, ROOT ('RegionSales')" QUERYOUT "d:\ temp\ test.XML"-c-t-T-S localhost
View the Test.XML file when the execution is complete, as shown in the following figure. You can see that the file format is so clear that it can be easily imported into other systems.
Data export to JSON
If you want to export data from SQL Server to Json, although there is a very mature way to do this in your application, SQL Server does not natively support this approach (grapevine, the next version will support it). I recommend using this post: jaminquimby.com/servers/95-sql/sql-2008/145-code-tsql-convert-query-to-json to do it. After the stored procedure provided by this post is established, use the following BCP command:
After the execution is completed, the result is as follows:
After reading this article, I believe you have a certain understanding of "how to export the data in SQL Server to XML and Json". If you want to know more about it, please follow the industry information channel. Thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.