I have a MSSQL table like such:
id | name
-----------------------------
1 Gerald
2 Ron
3 Becky
And an XML document:
<People>
<Person>
<Name>Gerald</Name>
</Person>
<Person>
<Name>Ron</Name>
</Person>
<Person>
<Name>Becky</Name>
</Person>
</People>
The primary key is ID, the XML document doesn't care about ID's, and Name's are unique.
The XML document changes, and my application should add new rows to the table for any <Person> not found in the SQL table.
Sure I can loop through the entire SQL table for each <Person> checking for a row and adding the row if it's not found, but is there a better way?
To add additional complexity, If I update a <Person>'s name in the XML file, it needs to update the same row that person was at before in the SQL table.