Overwriting Values From SQL Table to Another SQL Table

94 views Asked by At

I have 2 databases, a live and backup. I want to overwrite the the values in a specific field in the live database from those that are in the backup. The database structure is identical the only difference is there name.

How do I do this?

1

There are 1 answers

2
Richa On BEST ANSWER

Try this

UPDATE liveDB
  SET column2 = src.column2 -----Whichever column you want
FROM BackupDB.dbo.Table1 AS src
INNER JOIN LiveDB.dbo.Table1 AS dest
ON src.column1 = dest.column1;

Updated

UPDATE live
SET l.ola_m_1= b.ola_m_1
FROM live.dbo.order_line l
JOIN backup.dbo.order_line b
ON --Whatever is Similar column between two