使用 XQuery 在 SQL 查询中对 XML 的所有属性进行排序 [英] Sort all attributes of XML in SQL query using XQuery

查看:35
本文介绍了使用 XQuery 在 SQL 查询中对 XML 的所有属性进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 SQL 中使用 XQuery 获取具有排序属性的 XML?

How can get the XML with sorted attributes using XQuery in SQL?

例如对于这个 XML:

for example for this XML:

<root><book b='' c='' a=''/></root>

必须返回:

<root><book a='' b='' c=''/></root>

推荐答案

来自 xml 数据类型的限制.

不保留 XML 实例中属性的顺序.当你查询存储在 xml 类型列中的 XML 实例,顺序为生成的 XML 中的属性可能与原始 XML 不同实例.

The order of attributes in an XML instance is not preserved. When you query the XML instance stored in the xml type column, the order of attributes in the resulting XML may be different from the original XML instance.

因此,即使您能想出一种对属性进行排序的方法,您也不能相信 SQL Server 中的 XML 数据类型会保留您想要的顺序.

So even if you could figure out a way of sorting the attributes, you can not trust that the XML data type in SQL Server will preserve the order you want.

这篇关于使用 XQuery 在 SQL 查询中对 XML 的所有属性进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆