如何添加xml编码<?xml version="1.0"编码=“UTF-8"?>

2023-10-10数据库问题
1

本文介绍了如何添加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 输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

按天分组的 SQL 查询
SQL query to group by day(按天分组的 SQL 查询)...
2024-04-16 数据库问题
77

在 Group By 查询中包含缺失的月份
Include missing months in Group By query(在 Group By 查询中包含缺失的月份)...
2024-04-16 数据库问题
12

sql group by 与不同
sql group by versus distinct(sql group by 与不同)...
2024-04-16 数据库问题
37

如何在SQL中返回每个组的增量组号
How to return a incremental group number per group in SQL(如何在SQL中返回每个组的增量组号)...
2024-04-16 数据库问题
8

统计分组返回的记录数
Count number of records returned by group by(统计分组返回的记录数)...
2024-04-16 数据库问题
10

带聚合函数的 SQL GROUP BY CASE 语句
SQL GROUP BY CASE statement with aggregate function(带聚合函数的 SQL GROUP BY CASE 语句)...
2024-04-16 数据库问题
23