I love this solution. Very creative. I'm trying to see how it would work to take it a step further. I have xml data in a column and in that xml there are elements I want to number, but also want to extract the child elements also numbered.
So if the XML in the table (we'll call it scheduleInfo) is in a field called scheduleXML, is there a way to make it work.
So one sample record in the xml would look like:
What I'd like to get in my output is (position of the name, name, position of the class, class):
Any thoughts on how to do this? Seems I may have to break out the xml into another table to get the position, name and then the xml of the classes, and then possibly go from there? Very new to XML in SQL Server so trying to wrap my head around this. I couldn't even get this solution properly written to pull from a table instead of a variable (may have just missed something) so going further down is really twisting my brain.
commented on Aug 29 2012 12:50AM