Sort all attributes of XML in SQL query using XQuery

前端 未结 4 1853
执念已碎
执念已碎 2021-01-18 18:53

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

for example for this XML:

         


        
4条回答
  •  执笔经年
    2021-01-18 19:24

    From Limitations of the xml Data Type.

    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.

    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.

提交回复
热议问题