From: Roy Goldhammer on
Hello there.

I have two tables i need to insert table2 to table1.


the field: ID (unique identity) on table2 exist already on table1.

So i need insert the data to table1 and get new identity for each rows and
get table of the new identity vs old identity:

for examlple
vstable
old_iden, new_iden
5 , 12
6, 13
7, 14

I've tried to do it with output but it can't give me the old ID. is there a
way to do this without doing it one by one?


From: Philipp Post on
> I've tried to do it with output but it can't give me the old ID. is there a way to do this without doing it one by one? <

You could create a column "old_id" in the new table, then insert the
old table data into the new one

INSERT INTO new_table(old_id, -- other columns
)
SELECT id, -- other columns
FROM old_table;

Alternatively you could watch out for a primary key without using
IDENTITY to get rid of this, i.e. some data standard.

brgds

Philipp Post