Reputation: 5449
Hi I have accidently updated a row in SQL-SERVER that I should not have is there anyway to get the previous value of the row using this query:
UPDATE Documents
SET Name = 'Files'
WHERE Id = 950
Is there any way to recover the previous value?
Upvotes: 0
Views: 245
Reputation: 810
Yes, it is possible, but only under certain circumstances.
If you had wrapped the UPDATE
in a transaction, you could ROLLBACK
. This would undo the UPDATE
.
Assuming you didn't put it in a transaction, you need to reset the database to a previous point in time. This is only possible if you have some form of back-up on the database. How to do this is shown in this MSDN page
Not that both of these options will UNDO the update, not just tell you the previous values.
Upvotes: 1