Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy changed records into same Table

Status
Not open for further replies.

Delphard

Programmer
Jul 22, 2004
144
RS
Is there any way to select several records from one Table, and copy them back to same Table but with changed values of one field (for instance: values of Foreign key field)?
((records with original values needs to remain in Table))
Thanks in advance!
 
If you can write a select that extracts the info you want *including the different data*, then just stick "insert into yourtablename" in front of it.

If you can't write the select, then that's an entirely different problem.
 
Lets see example:
in Table1 I have articles with Supplier_ID as foreign key.
There is 5000 articles from Supplier1. Then, new supplier, Supplier2 appears with same articles. I need way to copy all of that 5000 articles just with changed Supplier_ID field.
 
Lets assume your Table1 has just two columns, Supplier_ID and Article_ID;
then try this:

insert into Table1
select 'Supplier2', Article_ID from Table1
where Supplier_ID = 'Supplier1';
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top