How to copy database contents from one SQL 2008 database to another


I have an SQL 2008 database (A) and I have a second 2008 database (B) that is configured with exactly the same tables but with different users and schema.

How can I copy contents of specific tables from data base A to the new database B?

Christopher ScheneSystem Engineer/Software EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I think you need to use the 4 part naming convention...


So, your Script for each table will go like this....

INSERT INTO Server.database.schema.TableB (Column1, Column2, Colum3)
SELECT Column1, Column2, Column3 FROM Server.database.schema.TableA

I am assuming your Table A schema will be dbo
I am assuming your Server is the same.


You could use the Data Insert Wizard in SSMS.
Choose a source, choose a destination, line the fields up. Run it....Boom data in.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Christopher ScheneSystem Engineer/Software EngineerAuthor Commented:
" am assuming your Table A schema will be dbo
I am assuming your Server is the same."

Actually table A and B schema are not DBO and are actually different names. For sake of example let's use the names  "SchemA and SchemaN".

Give me some time to look at the tech note.


Chris Schene
DBAduck - Ben MillerPrincipal ConsultantCommented:
The simplest way is to use the Import/Export wizard and you can select the source and then point it to the target schema/table and it will copy data from one to the other.

Right click on the database and choose Tasks then Import/Export Data.
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

Christopher ScheneSystem Engineer/Software EngineerAuthor Commented:
dbaduck: The twp databases are not on the same I tried exporting to excel and I got the table headers but not the data.
Investigate the setting up of a linked server.
Once you do that you can script between the 2.

It is odd there is no data when sending to excel. Are there a great many rows?

Try exporting to csv

Is the filter on your export query precluding any valid data?
Christopher ScheneSystem Engineer/Software EngineerAuthor Commented:
You approach worked.....but I forgot to ask about foreign key issues.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Distributions

From novice to tech pro — start learning today.