XML Parsing in SQL Server
问题 The requirement is to parse all the 27 values related to MarginRevenue/Cost/Value . As a standard scenario, these elements can come in any order and also can come in any number of time. In short, the XML is completely dynamic. The only point is Under Margins/Margin, there can be any number of MarginRevenue, MarginCost and MarginValue. declare @xml xml = '<Margins> <Margin type="type1" currencyCode="currencyCode1"> <MarginRevenue>1.1</MarginRevenue> <MarginRevenue>1.2</MarginRevenue>