I have xml files with data in the format:
etc
Trying to import this as a complex xml using SSIS but I need the data in the parent element attributes to be imported first, so that foreignkey constraints are complied with.
Prior to the xml import source routine I used SSIS SQL data task to obtain the highest/last id for the parent level xml's corresponding table. I then apply that value +1 to a variable (call it ParentId) which is used for all child tables in their foreignkey fields.
Then all of the xml source outputs are mapped to tables, including the xml parent level and corresponding table. I'm relying on this insert to create the id that I am assuming (i.e. the one I have assigned to the variable ParentId)
But the import fails because the parent output is not being processed first, so it never inserts that record and the parentid I am assuming is never generated.
Is there a way to enforce a priority or order that the xml source outputs are processed?
Solved
In case this helps anyone else.
What I did in the end is to use an xml task (xslt) to split the file into two, one for the parent and then another for the child records (the parent is always only one record).
Then I created two xml sources in sequence, first one imports the newly created parent xml, and using the same query & validation method mentioned in the first post obtains the correct identity value.
This is then used across all the child records in the second xml source task.
No comments:
Post a Comment