Tips: Sample SQL Script demonstrating moving row from one database table to another database table

Submitted by Nizam on

Many times such requirement comes wherein you need to copy data from one database to another database. Below is the sample sql script demonstrating the same.

You can use a three part qualifier like DatabaseName.Schema.TableName to address a table in a different database.

Use Database1

INSERT INTO Databas2.dbo.TableName
SELECT * FROM Database1.dbo.TableName

You just need to make sure the selected data matches the datatypes in the destination table.

Tags: