Tablecopy with T-SQL

Today i found myself in a situation where i needed to copy some data from one table on a MS-SQL server to another.

I found the following T-SQL syntax to be very helpfull.

UPDATE DST
SET
	DST.Title = SRC.Title,
	DST.ContractNumber = SRC.ContractNumber,
	DST.ContractDescription = SRC.ContractDescription
FROM
	Contracts AS DST
	INNER JOIN [SERVERNAME].[DBNAME].DBO.Contracts AS SRC
	ON DST.Id = SRC.Id
where
	SRC.Id > 500

Use at your own risk.

Leave a Comment

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