0

我犯了一个错误,我对我的主数据库(医院)进行了错误的更新(tblPatientFile 表中大多数患者的血型未知)但我有一个每日备份数据库(hospitalRapor),并且今天之前的患者数据是真实的(大约有400000条记录)

我可以像这样复制我的旧数据吗 [hospital].[dbo].[tblPatientFile].[bloodTypeField] = [hospitalRapor].[dbo].[tblPatientFile].[bloodTypeField] where [hospital].[dbo].[ tblPatientFile].[patientId] = [hospitalRapor].[dbo].[tblPatientFile].[patientId]

我遇到麻烦了,我必须在这一天解决这个问题。感谢您的帮助

4

2 回答 2

1

You didn't say a database server, so I can't be sure this will work, but I believe the syntax on MSSQL would be:

UPDATE livefile
SET livefile.bloodtypefield=oldfile.bloodtypefieild
FROM [hospital].[dbo].[tblPatientFile] livefile
INNER JOIN [hospitalRapor].[dbo].[tblPatientFile] oldfile on livefile.patientid=oldfile.patientid

I highly recommend running on a test database first to make sure it has the results you want. You will of course need a user who has access to both databases and depending on whether you have triggers etc defined that may take a long time to run on 400k rows.

于 2009-11-23T14:35:14.163 回答
0

我认为您在同一台服务器上恢复了数据库,在这种情况下,假设所有以前的数据都是正确的,您可以,尽管您会覆盖自错误以来对血型所做的任何更新。

我建议您在进一步操作之前还备份您的“不正确”数据库,以便可以纠正其他错误 - 轻松撤消,这样您至少可以返回初始“错误”状态而不是复合问题。

于 2009-11-23T13:28:56.603 回答