community.borland.com

Article #25731: How to copy a record from one table to another using SQL

Problem:
How can I copy a record from one table to another , using SQL?

Solution:
Note: This information was tested under InterBase 5.5.

Here is an example of how to copy a record from one table to another using SQL.  You can try
it yourself with the employee.gdb sample database that comes with InterBase 5.X.
(You will need to create a second table called dept2, with the
same field names and types as department, to hold the copy of the record.  )

Here is the query to copy a record from one table to another:

insert into  DEPT2 (DEPT_NO, DEPARTMENT,  HEAD_DEPT,  MNGR_NO,
        BUDGET,   LOCATION,  PHONE_NO)
          select DEPT_NO, DEPARTMENT,  HEAD_DEPT,  MNGR_NO, BUDGET,
        LOCATION,  PHONE_NO from department where mngr_no=105;


You can see that the record got inserted by doing this select command:

select * from dept2 where mngr_no=105

Last Modified: 23-OCT-00