Select from dbsource.table1 and insert dbtarget.table

S

ssafavi

I have two databases with identical tables.
I would like to select from one and insert into the other.
Since they are identical it would be a waste to select from
dbsource.table1 loop through the resultset and prepare the insert
statement into dbtarget.table1. Especially for a data transfer
activity.

Do you know any smart way of doing this?
Thanks
 
L

Lee Fesperman

ssafavi said:
I have two databases with identical tables.
I would like to select from one and insert into the other.
Since they are identical it would be a waste to select from
dbsource.table1 loop through the resultset and prepare the insert
statement into dbtarget.table1. Especially for a data transfer
activity.

Do you know any smart way of doing this?
Thanks

You didn't mention the DBMS you are using, but most support INSERT using a SELECT. For
example (assuming the two tables have identical columns, and they are defined in the
same order),

INSERT INTO target_table SELECT * FROM source_table

Check the docs for your DBMS.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top