What’s the most efficient way to copy a large amount of rows from a table in one database to another table in a different database that has the exact same structure?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If your log IO subsystem allows it, then:
But having the entire transfer occur in one single statement means one single transaction, which means that x2.5 data size log has to be generated and kept during the entire statement. Ie. if you transfer 50Gb, your target db log will grow to 250Gb (even if the recovery mode is set to simple!).
If you are concerned about log, then you have to transfer in batches. You can still do the INSERT … SELECT trick, but your SELECT has to use some key range and batch acceptable number of rows.
Ultimately, you can always do a
bcp outfollowed by abcp in, it will work pretty fast and is probably the fastest way to get a reliable transfer going.