Go Sql-create xml-how to set Unicode UTF-8

Source: Internet
Author: User
Tags ole

This article transferred from: Https://stackoverflow.com/questions/44754356/sql-create-xml-how-to-set-unicode-utf-8

I found a solution via another. (Don ' t remember which website I found it) See code below. This code would export my file in Utf-8-bom encoding.

DECLARE @OLE INT EXECUTE sp_oacreate ' ADODB.  Stream ', @OLE outputdeclare @Text xmlset @Text =  n ' This is the test test string '; --(SELECT TOP (1) [XML] From Vw_warp_leveranciers_xml) DECLARE @Converted NVARCHAR (max) SET @Converted = CONVERT (NVARCHAR (max), @Text) EXECUTE sp_OA SetProperty @OLE, ' Type ', 2--1 = binary, 2 = Textexecute Sp_oasetpro Perty @OLE, ' Mode ', 3--0 = Not set, 1 read, 2 write, 3 Read/writeexe CUTE sp_OASetProperty @OLE, ' Charset ', ' UTF-8 '--' iso-8859-1 ' EXECUTE sp_oasetp Roperty @OLE, ' lineseparator ', ' Adlf ' Execute sp_OAMethod @OLE, ' Open ' execute sp_OA  Method @OLE, ' writetext ', NULL, @Converted--text method--commit data and close text Streamexecute sp_OAMethod @OLE, ' SaveToFile ', NULL, ' d:\1.TXT ', 2--1 = notexist 2 = Overwriteexecute sp_OAMethod @OLE, ' Close ' EXECUTE sp_OADestroy  @OLEEXECUTE sp_OADestroy @OLE

Go Sql-create xml-how to set Unicode UTF-8

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.