0

What is the best way to create a copy of all data from database A in database B using SQL (and not a file copy)?

1 Answer 1

1

There is two approach check which one you prefers. but I think if possible i will follow first approach. But I have never done it.

First Approach Copy the first database and paste with some othername see following url

How to copy existing database from one app to another

Second Approach copy the contents of two database

Step-1 First Attach two databases

ATTACH DATABASE filename AS database-name;

The DATABASE keyword is optional, but I like the clarity of it. filename should be the path to the database file you wish to attach, and the database-name is a unique name.

Step-2 Run Insert Into commands for the tables you want to transfer.

INSERT INTO X.TABLE(Id, Value) SELECT * FROM Y.TABLE;
Sign up to request clarification or add additional context in comments.

1 Comment

The first approach suggest file copy which is not what I am looking for. As for the second one - can you please give a bit more detailed example (code snippet perhaps)? Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.