Reputation: 28248
I need to update my new database with data from 1 column in my old database. Basically based on matching ItemID's I need to set the Description column in my new DB with the values in the old DB. I can see what needs to be updated when I do a join but I am not sure how to handle this update properly.
Upvotes: 20
Views: 36231
Reputation: 452977
BEGIN TRANSACTION
UPDATE t1
SET Description = t2.Description
FROM db1.dbo.foo t1
JOIN db2.dbo.foo t2
ON t1.ItemID = t2.ItemID
SELECT * FROM db1.dbo.foo
--prevents changes from being committed
ROLLBACK
Upvotes: 35