如何添加xml编码<?xml version =“1.0”encoding =“UTF-8”?>到xml输出SQL Server

可能是一个没有答复的副本.
SQL Server 2008 – Add XML Declaration to XML Output

请让我知道,如果这是可能的.我读了一些博客

http://forums.asp.net/t/1455808.aspx/1

http://www.devnewsgroups.net/group/microsoft.public.sqlserver.xml/topic60022.aspx

但是我不明白为什么我不能这样做.

你必须手动添加它. SQL Server始终将xml内部存储为ucs-2,因此SQL不可能生成一个utf-8编码头

请参阅MSDN上的“Limitations of the xml Data Type”

The XML declaration PI,for example,<?xml version='1.0'?>,is not preserved when storing XML data in an xml data type instance. This is by design. The XML declaration (<?xml ... ?>) and its attributes (version/encoding/stand-alone) are lost after data is converted to type xml. The XML declaration is treated as a directive to the XML parser. The XML data is stored internally as ucs-2.

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念