如何从备份中的同一个表更新表?

时间:2021-12-25 17:04:58

I want to recover values from a table. I want to use the table from the backup. How to update a table from the same table in the backup?

我想从表中恢复值。我想使用备份中的表。如何从备份中的同一个表更新表?

This is the source

这是来源

UPDATE DbCurrent.dbo.Table1 AS Curr 
SET Curr.Value1 =  
(SELECT Bck.Value1 
  FROM DbBackup.dbo.Table1 Bck 
  WHERE Bck.Id = Curr.Id 
  AND Bck.Id2 = Curr.Id2
)

How do you do that?

你是怎样做的?

1 个解决方案

#1


1  

may be this will work fine

可能这样可以正常工作

UPDATE Curr  
SET Curr.Value1 =  Bck.Value1
From  Value1 Curr
  INNER JOIN Value1 Bck
  ON Bck.Id = Curr.Id  AND Bck.Id2 = Curr.Id2

#1


1  

may be this will work fine

可能这样可以正常工作

UPDATE Curr  
SET Curr.Value1 =  Bck.Value1
From  Value1 Curr
  INNER JOIN Value1 Bck
  ON Bck.Id = Curr.Id  AND Bck.Id2 = Curr.Id2