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)?

Asahi
  • 13,378
  • 12
  • 67
  • 87

1 Answers1

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;
Community
  • 1
  • 1
Sunil Kumar Sahoo
  • 53,011
  • 55
  • 178
  • 243
  • 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 – Asahi Dec 16 '11 at 06:57