transparent
Programmer
Hello.
I have a question regarding inputing data into a database from xml documents using openxml.
I have the following xml.
<incidents>
<incident id="10" name"crashed car">
<reporter id="2" name="ted"/>
</incident>
<incident id="11" name"crashed bike">
<reporter id="1" name="rick"/>
</incident>
<incident id="12" name"crashed spaceship">
<reporter id="3" name="paul"/>
</incident>
</incidents>
the tables involved are an incidents table, and a reporter table.
incident table has columns incidentid (PK), name
reporter table has columns reporterid(PK), incidentid(FK), name
Now to insert all the incidents
I would use
openxml(@itree,"/incidents/incident"
however with all the reporteres I need to extract the associated incidentID. How do I do this? Will
openxml(@itree,"/incidents/incident/reporter"
do it?
I have a question regarding inputing data into a database from xml documents using openxml.
I have the following xml.
<incidents>
<incident id="10" name"crashed car">
<reporter id="2" name="ted"/>
</incident>
<incident id="11" name"crashed bike">
<reporter id="1" name="rick"/>
</incident>
<incident id="12" name"crashed spaceship">
<reporter id="3" name="paul"/>
</incident>
</incidents>
the tables involved are an incidents table, and a reporter table.
incident table has columns incidentid (PK), name
reporter table has columns reporterid(PK), incidentid(FK), name
Now to insert all the incidents
I would use
openxml(@itree,"/incidents/incident"
however with all the reporteres I need to extract the associated incidentID. How do I do this? Will
openxml(@itree,"/incidents/incident/reporter"
do it?