I have a data flow task that extracts data from one database and inserts into a SQL Server database. After each record is inserted in the master row I also need to insert rows into a detail table. The data for the detail table is pretty simple and can be calculated.
- How do I retrieve the value of the identity column after inserting?
- How can I produce the rows that must be inserted in the second table? Can I do this in a script?
Do I need to use a Foreach loop at the control flow level which transfers the parent row in a data flow task, then have another Foreach loop which inserts the detail records?
Can I just perform all the detail row inserts in a script? That would probably be easier than putting in the Foreach loops.