Is there a way to parse (in a T-SQL script) the following XML without using multiple CROSS-APPLY statements? As you can notice the Root’s children have different names ( they are completely different — don’t only differ in the last digit index ).
I would like to shred this XML into a table where every MeasuredParamName* is a column and every value represents a row. Each MeasuredParamName element will have the same number of children.
ie. (MeasuredParamName1, MeasuredParamName2, MeasuredParamName3, MeasuredParamName4)
Is there a performance concen with using cross-apply for this solution? Would a different structure for the XML be more suitable?
Ex:
<Data>
<MeasuredParamName1>
<Value>1</Value>
<Value>2</Value>
</MeasuredParamName1>
<MeasuredParamName2>
<Value>3</Value>
<Value>4</Value>
</MeasuredParamName2>
<MeasuredParamName3>
<Value>0.5</Value>
<Value>0.10</Value>
</MeasuredParamName3>
<MeasuredParamName4>
<Value>20</Value>
<Value>30</Value>
</MeasuredParamName4>
</Data>
Try this.
If I were designing the XML, I would put the “row” values inside the columns.
eg