views:

60

answers:

1

I've a master table with identity on for the primary key and I've some child tables. When I insert a record to the master table using BCP, how can I use the newly created ID from the master table to insert in the related child tables (May be BCP again)? Will it be possible? I may be able to set identity off, but, will it work?

Thanks Joseph

A: 

Sorry, was out of town. Yes, the relationships already exists in the target system. When I insert a record in the master table, it is going to auto-generate new identity in the primary column. I need to take that ID and insert as the foreign key when I insert the child table data. I'm using BCP from .dat files for both master and child tables. The external .dat file already having some id exists, but, I don't need that, let the target system creates the new identity. Only thing is, I need to maintain the relationships when I insert the child records to the child table. Hope this is more clear. Thanks in advance. Joseph

Joseph
I think what you said is that the IDs already link up in the current data, but you would like to insert the data and then link it again, with the new identify columns. Is that right?
MJB