Finding node order in XML document in SQL Server

前端 未结 6 1394
死守一世寂寞
死守一世寂寞 2020-12-01 04:41

How can I find the order of nodes in an XML document?

What I have is a document like this:


    
            


        
6条回答
  •  伪装坚强ぢ
    2020-12-01 05:20

    The answer by erikkallen is absolutely correct.

    However, if the original document/schema may be modified, an alternative is to store the position/index in an attribute. I use a mix of both approaches, depending who the "originator" of the XML is and the type of queries that need to be performed upon it. At the end of the day I rue most use of XML except possibly "dumb storage" in SQL Server and am usually happy when I can dump it (XML) for normalized tables.

    Happy dealing with the unmentioned limitations of "enterprise-grade" products -- the wonders never end.

提交回复
热议问题