可能是 unanswered 的重复。 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 编码 header
参见 "Limitations of the xml Data Type"在 MSDN 上
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.
关于sql-server - 如何将 xml 编码 <?xml version ="1.0"encoding ="UTF-8"?> 添加到 SQL Server 中的 xml 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9002403/