SQL iteration for XML

I am trying to read an xml data field from a table and insert this data into another database. The XML document looks like this:



1
2
3
4

My idea is to get 1 id and insert it to get another And insert, and so on. I try to use xquery, but the best I can get is all the data, but I need to insert id separated:/

Does it help? d:

declare @xml xml ='

1
2
3
4< br />

'insert into YourTable(ID)select TNvalue('.','int')from @xml.nodes('/Master/UserIds/id') as T(N)

I am trying to read an xml data field from a table and insert this data into another database. The XML document looks like this:

< /p>



1
2
3
4

My idea is to get 1 One id and insert, get another and insert, and so on. I try to use xquery, but the best I can get is all the data, but I need to insert id separation:/

Does it help? ? d:

declare @xml xml ='

1
2
3
4

< /Master>'insert into YourTable(ID)select TNvalue('.','int')from @xml.nodes('/Master/UserIds/id') as T(N)

Leave a Comment

Your email address will not be published.