Possible to get PrimayKey IDs back after a SQL BulkCopy?

Posted by chobo2 on Stack Overflow See other posts from Stack Overflow or by chobo2
Published on 2010-05-31T18:50:14Z Indexed on 2010/05/31 18:53 UTC
Read the original article Hit count: 251

Filed under:
|
|
|

Hi

I am using C# and using SqlBulkCopy. I have a problem though. I need to do a mass insert into one table then another mass insert into another table.

These 2 have a PK/FK relationship.

Table A
Field1 -PK auto incrementing (easy to do SqlBulkCopy as straight forward)

Table B
Field1 -PK/FK - This field makes the relationship and is also the PK of this table. It is not auto incrementing and needs to have the same id as to the row in Table A.

So these tables have a one to one relationship but I am unsure how to get back all those PK Id that the mass insert made since I need them for Table B.

© Stack Overflow or respective owner

Related posts about c#

Related posts about sql