{"id":1088,"date":"2010-05-08T22:09:55","date_gmt":"2010-05-08T20:09:55","guid":{"rendered":"https:\/\/www.peppercrew.nl\/?p=1088"},"modified":"2011-05-18T20:48:57","modified_gmt":"2011-05-18T19:48:57","slug":"exporting-data-from-sql-to-xml","status":"publish","type":"post","link":"https:\/\/ingmarverheij.com\/en\/exporting-data-from-sql-to-xml\/","title":{"rendered":"Exporting data from SQL to XML"},"content":{"rendered":"<div>Exporting data from a SQL database to a XML file is very easy, if you know how to.<br \/>\nUsing the <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/ms162802.aspx\">bcp<\/a> command (bulk copy program), a tool supplied by Microsoft, you can easily export all the data you want.<\/div>\n<div>&#8211; Create a new text file and type the following text:<br \/>\n<code><br \/>\n&lt;root&gt;<br \/>\n&lt;\/root&gt;<br \/>\n<\/code><br \/>\n&#8211; Save the text file with a .xml extension, for instance data.xml;<br \/>\n&#8211; Open a new Command Prompt (as Administrator in Vista\/Win7\/2008 R2);<br \/>\n&#8211; Execute the following command : bcp.exe &#8220;SELECT * FROM Table AS XML RAW&#8221; queryout data.xml -c -r -t -T.<\/div>\n<div>If you want to script the process with batch (we&#8217;re a big fan of batch files) you can use the following script:<br \/>\n<code><br \/>\n@Echo Off<\/code><\/div>\n<p><code><\/p>\n<div>REM Create an empty XML file<br \/>\nECHO\u00a0^&lt;root^&gt; &gt;data.xml<br \/>\nECHO ^&lt;\/root^&gt; &gt;&gt;data.xml<\/div>\n<div>REM Export the data using BCP<br \/>\nbcp.exe \"SELECT * FROM Table AS XML RAW\" queryout data.xml -c -r -t -T.<\/div>\n<p><\/code><\/p>\n<div>Ingmar Verheij &amp; Daniel Nikolic<\/div>","protected":false},"excerpt":{"rendered":"<p>Exporting data from a SQL database to a XML file is very easy, if you know how to. Using the bcp command (bulk copy program), a tool supplied by Microsoft, you can easily export all the data you want. &#8211; Create a new text file and type the following text: &lt;root&gt; &lt;\/root&gt; &#8211; Save the [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[304],"tags":[171,85,173,174],"class_list":["post-1088","post","type-post","status-publish","format-standard","hentry","category-batch-scripting","tag-bcp","tag-export","tag-sql","tag-xml"],"_links":{"self":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/1088","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/comments?post=1088"}],"version-history":[{"count":2,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/1088\/revisions"}],"predecessor-version":[{"id":2303,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/1088\/revisions\/2303"}],"wp:attachment":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/media?parent=1088"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/categories?post=1088"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/tags?post=1088"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}