Copy one database to another database

匆匆过客 提交于 2019-12-23 22:36:31

问题


How to copy from one database to another database.

Database name visco

I want to copy all the table from visco database to new database name as neptune

I was created one database with out any tables, then i try to restore the database from database1.bak file, then it is showing error as

You are attempting to overwrite an existing database.  Check the force restore over existing database option to 
overwrite the existing database.

Need Query Help


回答1:


Using the SQL Server Management Studio:

Option 1

-> Right click on the database you want to copy
-> Choose 'Tasks' > 'Generate scripts'
-> 'Select specific database objects'
-> Check 'Tables'
-> Mark 'Save to new query window'
-> Click 'Advanced'
-> Set 'Types of data to script' to 'Schema and data'
-> Next, Next :)

You can now run the generated query on the new database.

Option 2

-> Right click on the database you want to copy
-> 'Tasks' > 'Export Data'
-> Next, Next :)
-> Choose the database to copy the tables to
-> Mark 'Copy data from one or more tables or views'
-> Choose the tables you want to copy
-> Finish




回答2:


There is not one, but several options to achieve what you want. Your question is not very specific in that respect. You may find this article "SQL SERVER – 2008 – Copy Database With Data – Generate T-SQL For Inserting Data From One Table to Another Table" useful:

http://blog.sqlauthority.com/2009/07/29/sql-server-2008-copy-database-with-data-generate-t-sql-for-inserting-data-from-one-table-to-another-table/

If that leaves unanswered questions let us know.




回答3:


Build an SSIS package and use the "Transfer SQL Server Objects Task"

Example

Documentation




回答4:


Check out the products of Atlantis Interactive, free and licensed for commercial use

They are similar to Red Gate's products and have the ability to synchronize schema and data between databases.




回答5:


You could export the tables and info and, that file, import it to the new data base. The file usually could be saved as a .sql

Check: http://msdn.microsoft.com/en-us/library/ms140052.aspx




回答6:


One easy way would be to take a backup of the existing database and then restore that backup to a new database.

Check out this technet article for information on backing up and restoring databases using Enterprise Manager: Backup & Restore Database using Enterprise Manager



来源:https://stackoverflow.com/questions/9703594/copy-one-database-to-another-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!