|
Is there a way to copy an existing record using SQL except for the key? There is something way back in the recesses of my mind that says yes, but I haven't been able to come up with syntax that works.Not pretty, but there are two SQL options that I can think off:
A statement like "Insert into myfile (select * from myfile where key = 1) " should copy a record with key = 1 and insert it. But in a uniquely keyed file, it would cause a duplicate key error. Can I create a new record with a new key value without identifying all the existing fields? If my first field is the key, having to do something like "insert into myfile (select '2',field2,field3,field4,field5,field6....field50 from myfile where key = 1) would create a valid new record with a key of '2' but is a hassle to code all the field references when there are a bunch of them (50 in this example).
Any tricks here or do I need to include all the fields in the select statement individually in order to create a "copy" and insert it with a new key value.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.