Probably a duplicate of unanswered. SQL Server 2008 - Add XML Declaration to XML Output
Please let me know if this is possible. I read in some blogs
http://
I have been working with this matter during the last days, and although there might be better solutions, I have ended up quite happy with this bash script:
iconv -f UCS-2 -t UTF-8 products.xml > products_utf8.xml
echo "\n\n$(cat products_utf8.xml)\n " > products_utf8_final.xml
Basically, this script will get a file generated from the horrible bcp software, which generates incomplete and invalid XML data, convert it from the UCS-2 format to UTF-8 (first row), and add at the beginning and end of the file what it needs (second row of the script) to be valid and complete.
It works for me. The script I used to generate the XML file with BCP is:
bcp.exe "select * from dat1.dbo.Products FOR XML AUTO,ELEMENTS” queryout "C:\products.xml" -T -w -r -S .\SQLEXPRESS