March 25, 2014 at 4:11 am
Hi All,
I need to insert approximately 500k rows into sql, but on each insert i need to get the inserted row id so i can perform insert into another table.
eg:
Table A
col1_ProductId | cold2_Name
1 | Product1Name
2 | Product2Name
Table B
col1_ID | col2_ProductId | Attribute
1 | 1 | blue
2 | 1 | small
3 | 2 | red
4 | 2 | large
I'm after the most efficient way possible as the task will be repeated regularly.
Thanks in advance
March 25, 2014 at 4:28 am
CookieMonster (3/25/2014)
Hi All,I need to insert approximately 500k rows into sql, but on each insert i need to get the inserted row id so i can perform insert into another table.
eg:
Table A
col1_ProductId | cold2_Name
1 | Product1Name
2 | Product2Name
Table B
col1_ID | col2_ProductId | Attribute
1 | 1 | blue
2 | 1 | small
3 | 2 | red
4 | 2 | large
I'm after the most efficient way possible as the task will be repeated regularly.
Thanks in advance
Are you attempting to do the INSERT in one large operation or one after the other from a front end or something along those lines?
You can use the OUTPUT Clause to fetch Identity ID's inserted in a Table.
March 25, 2014 at 4:50 am
cheers for the reply, I will take a look at OUTPUT clause,
I'm not sure, I'm just looking for the most efficient way, would it be quicker to do a bulk insert and then select from the to insert into other tables or is it more efficient to insert row by row with a nested insert?
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply