I will give an example of the pseudocode of my current method, and if anyone knows about a method that does not work one line at a time, I would be very grateful. I am using MS SQL Server 2008.
define cursor for the data to be inserted (about 3 million records) loop ( insert record into table 1 use scope_identity() to get key insert record into table 2 that references table 1 )
I would rather do some kind of insertion into both tables at the same time, because the cursor and the loop are slow.
Before I talk about why I insert something into two separate tables that are 1 to 1 related, this is because the first table cannot be changed, and I need the information in the second (temporary) table to reference for data conversion later.
No, I canβt add a temporary column to store the referenced data in a table that cannot be modified because it cannot be changed. This is a living system, and I do not have permission to modify the table.
Thanks!
Additional Information:
Example
Source: 1 a big monkey 2 a tall elephant 3 a big giraffe 4 a tiny cow 5 a tall cow Dest: Table 1 Table 2 monkey 1 big elephant 2 tall giraffe 3 big cow 4 tiny cow 5 tall
sql-server bulkinsert foreign-keys cursor
Appfzx
source share