-- dummy schema
CREATE TABLE TMP ( data VARCHAR(MAX) );
CREATE TABLE [Table1]
(
id INT NOT NULL
IDENTITY(1, 1) ,
data VARCHAR(MAX)
);
CREATE TABLE [Table2]
(
id INT NOT NULL
IDENTITY(1, 1) ,
id1 INT NOT NULL ,
data VARCHAR(MAX)
);
-- imagine this is the SqlBulkCopy
INSERT TMP
VALUES ( 'abc' );
INSERT TMP
VALUES ( 'def' );
INSERT TMP
VALUES ( 'ghi' );
-- now push into the real tables
INSERT [Table1]
OUTPUT INSERTED.id ,
INSERTED.data
INTO [Table2] ( id1, data )
SELECT data
FROM TMP;
https://stackoverflow.com/questions/2945414/possible-to-get-primaykey-ids-back-after-a-sql-bulkcopy