If I have the XML like the following: (As an XML variable names @nodes)
<Nodes>
<Item>Item 1</Item>
<Item>Item 2</Item>
<Item>Item 3</Item>
</Nodes>
And I also have the index of the item I am looking for (example 2). How can I get the value 'Item 2' using a query?
I have been trying something like this:
SELECT
@result = @nodes.value('(/Nodes/Item)[2]', 'nvarchar(255)')
But all I can seem to get back is NULL