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 输出
基础教程推荐
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
