How can I find the order of nodes in an XML document?
What I have is a document like this:
You can get the position of the xml returned by a x.nodes()
function like so:
row_number() over (order by (select 0))
For example:
DECLARE @x XML
SET @x = 'abc1 def1 abc2 def2 '
SELECT
b.query('.'),
row_number() over (partition by 0 order by (select 0))
FROM
@x.nodes('/a/b') x(b)