Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
X-Factor
Constraint Violating Yak Guru
392 Posts |
Posted - 2003-11-11 : 07:45:25
|
| I have sent some parents and their children to a stored procedure in some XML.At the database the parents and children are loaded into seperate temp tables.Then, I have a 'while' loop which iterates through each of the parent items and inserts each one. For each item, the '@@identity' is stored and then there is an inner loop which iterates through each of the child items and intserts them setting their foreign key to the identity of the parent previously stored.Is this the typical way that one inserts records related in this way or is there a fancy set based method?I figure that the important thing is to get hold of the identity of the parent so that the child items can reference it.Cheers. |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2003-11-11 : 08:12:25
|
| There are some good (fancy) articles on parent / child operations on this website. The easiest find is to do SEARCH on PARENT CHILD on the home page.Here's the result of that search. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-11-11 : 12:40:47
|
| I think you need to look up SCOPE_IDENTITY in BOLBrett8-) |
 |
|
|
|
|
|