Thanks! That worked but of course I forgot to mention that I have the change the product name field so the user knows which one the the new record is (copy of Bike 101). The customer is tired of entering the same data so he just want to copy a product then change the name.


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Daniel Elmore
Sent: Thursday, April 21, 2005 1:50 AM
To: [email protected]
Subject: [SPAM-Connection] RE: Coping sql database record

If you use an INSERT INTO SELECT statement, then you can do it all in one query.

 

INSERT INTO someTable (col1,col2,col3)

SELECT col1,col2,col3

FROM someTable

WHERE ID = ….

 

That will insert one record, if you want to duplicate it multiple times, you can inflate the SELECT query to return more than one record. If this is a frequent need, I would create a table of “templates” and select the values from the template table instead of the data table.

 

Daniel

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Terry Blake
Sent: Thursday, April 21, 2005 1:37 AM
To: [email protected]
Subject: Coping sql database record

 

Is there a way to copy a sql record(s)? Right now I just do a cfquery and then loop over <query>insert...</query> to create the new records. This works but there must be a better way.

 

Thanks for any help!

Terry

Reply via email to