简体   繁体   English

在SQL中对XML属性进行排序

[英]Sort XML Attributes in SQL

How to sort XML Attributes in SQL? 如何在SQL中对XML属性进行排序?

for example for this XML: 例如此XML:

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

I want: 我想要:

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

From http://msdn.microsoft.com/en-us/library/ms187107%28v=sql.90%29.aspx : 来自http://msdn.microsoft.com/zh-cn/library/ms187107%28v=sql.90%29.aspx

The order of the XML attributes is not preserved. XML属性的顺序不会保留。 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. 当查询存储在xml type列中的XML实例时,结果XML中的属性顺序可能与原始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. 因此,即使您能找到一种对属性进行排序的方法,也不能相信SQL Server中的XML数据类型将保留您想要的顺序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM