BitResQ » Simple Tricks to Copy Table From One Database to Another

Simple Tricks to Copy Table From One Database to Another

Shubham Dixit   
Published: May 1, 2023 • Move , SQL • 5 Minutes Reading

In today’s world of data-driven decision-making, businesses rely heavily on databases to store, organize, and manage their valuable information. However, as companies grow and evolve, they often face the challenge of transferring data between databases. One common scenario is the need to copy table from one database to another. In this article, we will explore the reasons why companies may need to copy a table from one database to another and the best ways to achieve this task.

Why Copy Table Data From One Database to Another?

There are several reasons why a company or an individual may need to copy table from one database to another. Among the most typical causes are:

  • Data consolidation: As companies grow, they may acquire different systems that store similar data in different databases. Consolidating this data into a single database can help streamline operations and improve decision-making.
  • Data migration: When companies upgrade or replace their existing database system, they may need to migrate data from the old system to the new one.
  • Reporting: Companies may need to generate reports that combine data from multiple databases. In such cases, copying a table from one database to another can be a quick and easy way to achieve this.
  • Backup and disaster recovery: Creating backups of important tables in multiple databases can help companies recover from data loss due to hardware failure or other disasters.

Best practices to Copy Table From One Database to Another

When copying tables between databases, companies should follow several best practices to ensure the process is smooth and error-free. The following are some of the most significant best practices:

  1. Plan the process: Companies should carefully plan the table copying process, including identifying which tables to copy, selecting the best method, and scheduling the task at a time that will have minimal impact on operations.
  2. Test the process: It is important to test the process of copying tables between databases before doing it in a production environment. Also, monitor the process closely. This can help identify any errors or performance issues and allow for quick resolution.
  3. Ensure data integrity: It is important to ensure that the data is transferred accurately and without any errors. This can be achieved by verifying data at each stage of the process and performing data validation after the process is complete.

How a User Can Copy Table From One Database to Another?

There are several methods to copy a table from one database to another. However, in this post, we will be explaining how to copy table data from one database to another in SQL server using two useful methods.

Generating Script in SQL Server

To copy all objects, indexes, triggers, constraints, etc., use “Generate Scripts…”. Let’s say we have a Test database. Right-click the Test database once more and choose “Generate Scripts…” database Name -> “Tasks” -> “Generate Scripts….”

  1. Select “Generate Scripts…” after that. It will launch the Generate Scripts wizard.
  2. Select tables and stored procedures by pressing the “Next” button now.
  3. Now press the “Next” button and provide the correct name and file path.
  4. Once you have reviewed your source and target locations, click the “Next” button.
  5. Click the “Next” button now.
  6. At last, press the “Finish” button.

The Test database’s script file has been created. Choose the location of the file on your computer to view the created script file.

Making a SQL Server Database

 To build a new database, follow these steps:

  1. To launch and expand the Object Browser in SQL Server Management Studio, press F8.
  2. Right-click the database and choose to Create a new Database.
  3. This would launch the window for “New Database“.
  4. To create a database, enter a name now.
  5. To build the database, click the OK button now. The Object Explorer will display the new database.

The database, which is now called DatabaseTest, has been made. Now,  we have to copy table from one database to another:

Transfer Data and Database Schema to Another Database

  1. Right-click the script file, open it in Notepad, copy all the information, and then paste it into SQL Server’s query box. It will appear like in the next image.
  2. Only now should the database test be changed to DatabaseTest.
  3. To run the script and expand the DatabaseTest to view the schema and data, press F5.

Automated Way to Recover & Copy Table data From One Database to Another

In some cases, users unintentionally delete their data table from DB. So, to copy/transfer those table data to another database SQL Recovery Tool could be the best solution to use. The Repair and restore damaged MDF & NDF Files, provides the option to preview Deleted Database Objects in SQL. Also helps to Recover Deleted Stored Procedures, Tables, Functions etc.

Download Now Purchase Now

Guided Steps to Recover & Copy Table From One Database to Another

1. Download and launch the utility for restoring and copying table data.

copy table from one database to another

2. Then select Open for inserting the files(MDF or NDF).

copy table from one database to another

3. In the Scan Mode section – Opt for Advance Scanning, don’t forget to mark the Recover Deleted Objects.

applying scanning options

4. Preview all recovered items. Now, hit the Export button.

previewing the recovered items

5. Finally, in the next window, select & fill in the details required and press the Export button.

copy table from one database to another

Also Read: Ultimate Guide to Recover Deleted Records in SQL Server


To copy table from one database to another is a common task that companies may need to perform for various reasons. Hence there are some of the methods that can be used to accomplish this task. Using the SQL Commands one can easily know how to copy table data from one database to another in SQL server.

However, in the case of copying deleted tables, the manual way will not work. Hence, a professional solution will work for you to recover the deleted tables and transfer them to a new database. Following best practices can help ensure a smooth and error-free process.