3

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

JetJack
  • 978
  • 8
  • 26
  • 51

6 Answers6

5

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

David
  • 3,736
  • 8
  • 33
  • 52
  • Showing error as "You are attempting to overwrite an existing database. Check the force restore over existing database option to overwrite the existing database." – JetJack Mar 14 '12 at 14:50
  • One must copy the SQL into a new Query on the new Database, changing the referenced database at the top of the query--but worked like a charm. – xy0 Jun 28 '23 at 20:32
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.

ExternalUse
  • 2,053
  • 2
  • 25
  • 37
1

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

Example

Documentation

Diego
  • 34,802
  • 21
  • 91
  • 134
1

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.

Jeremy Gray
  • 1,378
  • 1
  • 9
  • 24
0

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

0

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

Tim Lentine
  • 7,782
  • 5
  • 35
  • 40
  • Showing error as "You are attempting to overwrite an existing database. Check the force restore over existing database option to overwrite the existing database." – JetJack Mar 14 '12 at 14:50
  • When you use the restore method, instead of selecting an existing database type the new database name that you wish to use. You also will likely need to select the "Options" tab and change the "Restore As" file name for both the mdf and ldf files. – Tim Lentine Mar 14 '12 at 16:57