I have an SQL Server (Microsoft SQL Server Express Edition, version 10.50.1600.1) with two databases. I want to copy all contents from one to the other, and I want to do this programatically with Java.
Alternatively if there is a way (from Java code) to clone the database to create an identical copy, that would work too.
The solutions I've found so far seem to fall in to two categories:
- Get a resultset of all tables from source, for each table, copy it into destination
- Dump source to a file, import the file to destination
Is there probably a more simple solution to this?
Background:
We have tests that write to the database, so we need to create a fresh db for each test and to pass the tests it needs to be identical to the source.