Can anyone please show me how to turn the following XML string into a table variable with the following structure:
DECLARE @xml XML = '<?xml version="1.0" encoding="UTF-8"?>
<skillsProfilesTargets>
<skill ID="1">
<profile ID="50" targetLevel="75" />
<profile ID="60" targetLevel="75.00"/>
<profile ID="70" targetLevel="60.00"/>
</skill>
<skill ID="2">
<profile ID="50" targetLevel="75" />
<profile ID="60" targetLevel="50.00"/>
</skill>
<skill ID="3">
<profile ID="50" targetLevel="" />
<profile ID="60" targetLevel="75"/>
<profile ID="90" targetLevel="60.00"/>
</skill>
<skill ID="4">
<profile ID="50" targetLevel="" />
<profile ID="60" targetLevel="75"/>
<profile ID="100" targetLevel="75"/>
<profile ID="250" targetLevel="100"/>
</skill>
</skillsProfilesTargets>'
SkillID profileID targetLevel
-----------------------------------
1 50 75
1 60 75
1 70 60
2 50 60
2 60 50
3 50 NULL
3 60 75
I've been looking at a number of tutorials online, but they all assume each 'skill' node has the same number of child nodes.
Thanks in advance.