How to add xml encoding lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt; to xml Output in SQL Server(如何添加xml编码?xml version=1.0编码=“UTF-8?到 SQL Server 中的 xml 输出)
问题描述
可能是未答复的副本.SQL Server 2008 - 向 XML 输出添加 XML 声明
如果可能,请告诉我.我在一些博客中读到
Please let me know if this is possible. I read in some blogs
http://forums.asp.net/t/1455808.aspx/1
http://www.devnewsgroups.net/group/microsoft.public.sqlserver.xml/topic60022.aspx
但我不明白为什么我不能这样做.
But I couldn't understand why I can't do this.
推荐答案
您必须手动添加它.SQL Server 总是在内部将 xml 存储为 ucs-2,因此 SQL 不可能将其生成为 utf-8 编码标头
You have to add it manually. SQL Server always stores xml internally as ucs-2 so it is impossible for SQL to generate it a utf-8 encoding header
请参阅 xml 数据类型的限制" 在 MSDN 上
See "Limitations of the xml Data Type" on MSDN
将 XML 数据存储在 xml 数据类型实例中时,不会保留 XML 声明 PI,例如 <?xml version='1.0'?>
.这是设计使然.数据转换为 xml 类型后,XML 声明()及其属性(版本/编码/独立)丢失.XML 声明被视为 XML 解析器的指令.XML 数据在内部存储为 ucs-2.
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.
这篇关于如何添加xml编码<?xml version="1.0"编码=“UTF-8"?>到 SQL Server 中的 xml 输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何添加xml编码<?xml version="1.0"编码=“UTF-8"?>到 SQL Server 中的 xml 输出


基础教程推荐
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- Sql Server 字符串到日期的转换 2021-01-01