你也可以执行一个INSERT/SELECT操作,在基于恢复数据库的一个查询的生产数据库上插入纪录。因为我们的Order Details表没有IDENTITY栏,所以可以通过在一张临时表中插入纪录和使用ROW_NUMBER()函数来自己创建这一栏。
--This inserts records in a temporary table and assigns a dummy identity value for reference
SELECT ROW_NUMBER() OVER (ORDER BY OrderID) AS ROWID, *
INTO Northwind_recover.dbo.OrderDetailsRecover
FROM [Order Details]
--This inserts recovered records from the recovered database into the production database based on
--the dummy identity valuewe have assigned for reference
INSERT INTO Northwind.dbo.[Order Details] (OrderID,ProductId,UnitPrice,Quantity,Discount)
SELECT OrderID,ProductId,UnitPrice,Quantity,Discount
FROM Northwind_recover.dbo.OrderDetailsRecover
WHERE ROWID>
(
SELECT COUNT(*)
FROM Northwind_RestorePointSnapShot.dbo.[Order Details]
)
请注意,我们使用数据库快照来识别我们所设法还原的和我们所恢复的区别。
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/