user4762012
user4762012

Reputation:

how to copy one database tables data to another empty database in sql server?

I have one database named SeoAppDB1 I want to copy all content into another database seoapp3 using queries.

I need a query to copy tables and data as it is from source db to destination database. How can I do this?

Upvotes: 1

Views: 687

Answers (2)

Neil P
Neil P

Reputation: 3210

as @Dan-Guzman mentioned in his comment, you should use a backup and restore if you have backups available.

You can also use the wizard through SSMS (right click on the database -> Tasks -> Copy Database

Then follow the instructions, select your source and destination servers and set the method you wish to use to copy. Note that you may need to take the database offline or hurt system performance if you keep the database online.

Upvotes: 1

praveen_programmer
praveen_programmer

Reputation: 1062

You can use query like this.

USE OtherDB;

SELECT *
INTO NewTable
FROM FirstDB.Schemaname.OldTable

It will create new table in second database with name NewTable from the oldTable.

Upvotes: 0

Related Questions