I am passing the following xml to a SQL Server stored procedure:
<root>
<id>6063</id>
<id>6064</id>
</root>
In my stored procedure I have the following code to select the id:
SELECT t.n.value('id[1]', 'int')
FROM @xml.nodes('/root') as t(n)
Now this works however it obviously only selects the first id and stops. I am not quite sure how to make this 'loop' and select all the id's in the xml file.
Any help greatly appreciated.
Here is the full stored procedure for reference:
BEGIN
DECLARE @xml xml = '<root>
<id>6063</id>
<id>6064</id>
</root>'
SELECT t.n.value('id[1]', 'int') as id
FROM @xml.nodes('/root') as t(n)
END