I've searched for a solution to this, and found several examples, but none have been exactly right for my scenario.
I've got a [source] table, and two destination tables [table1] and [table2]. [table1] and [table2] both have an Id column (UniqueIdentifier). All columns in [table1] have default values, including the UniqueIdentifier.
[table1] is a parent to [table2], and contains date-time data to track when records were inserted, modified, deleted. [table2] is a detail table, describing records in [table1].
I need to SELECT all from [source], and INSERT into [table1] and [table2], retaining Id generating during [table1] insert, so I can insert this same Id into [table2] along with the data selected from [source].
[source]
col1, col2, col3, col4 <------This data needs to be inserted into [table2]
[table1]
Id*, date-created, date-modified, to-date <-------these all have default values
[table2]
Id*, name, description, category <-------Id generated in [table1] needs to match here
Hopefully I made this clear. Let me know if you need more details. Thanks!