Saturday, March 2, 2013

[SQL Server] Insert to Parent/Child tables

[SQL Server] Insert to Parent/Child tables


Insert to Parent/Child tables

Posted: 02 Mar 2013 01:34 AM PST

I have a Parent table (Identity PK with 600,000+ rows) and a child table (with maybe 20,000 rows). The parent and child share the same PK (1 to {0 or 1} relationship). This was done (in hindsight I shouldn't have...) because the child table population is sparse.I have some new adds to the table in a "flattened" version...that is, the child contents are part of the parent row.I want to insert the new additions to the Parent/Child table, but I won't know the PK on the parent until the parent row is inserted. How does one accomplish this?

No comments:

Post a Comment

Search This Blog