The simplest way to copy sql tables from one database to another?

Posted on

Question :

So I have been logged into two different database. I want to copy one table from the first database to the other one with its content. I want to overwrite the content of the destination one (Because I have the same table name but it has just few entries) So what is the simplest way to do it?

PS: I am using Microsoft SQL Server Management Studio 2019 and each database located on different server.

Answer :

This article lists out three simple ways to copy data from one table to another. To summarise, you can use the Import/Export Wizard in SSMS to copy data from one table to another. You can use the “Generate Scripts” option to generate a script of schema and data from the source then drop your target table and run the script against your target. Lastly, you can use INSERT INTO ... SELECT ... to transfer data from one table to another.

For your scenario, the easiest option is the Import/Export Wizard for a one-off transfer. If you want to repeat this transfer, a simple solution would be to create a linked server on your target SQL Server connecting to your source SQL Server and use the INSERT INTO SELECT option.

Leave a Reply

Your email address will not be published. Required fields are marked *