Reputation:
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
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
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