Stored procedure to duplicate a record.
Posted on 2002-06-08
Probably a basic question for most of you ...
So here we go:
I have two tables: (Example)
I want a stored procedure that will take three parameters
existing id, new id and new firstname.
The stored procedur should look up the 'existing id' in table1 and copy that row (record) to a new row with the parameter 'new id' as the data for the id field in table1.
At the same time a new record should be created in table2, also with the parameter 'new id' as the id.
There should be a check for duplicates and an error message needs to be generated if you would ask it to create a new id which already exists.
Hope you guys get this poor explanation in bad english :)
Many thanks in advance,