Sort XML Attributes in SQL

放肆的年华 提交于 2019-12-25 05:13:34

问题


How to sort XML Attributes in SQL?

for example for this XML:

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

I want:

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

回答1:


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

The order of the XML attributes 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.

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.



来源:https://stackoverflow.com/questions/10630136/sort-xml-attributes-in-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!