Colonel Panic
Colonel Panic

Reputation: 105

Undo changes in SQL Server database since last restore

Let’s say I restore a database (say db1) from a backup (backup1.bak) and then modify a few tables in db1. At this point, if I want to go get rid of the changes and go back to the restored state, how can I do that? Currently, I am creating a new database (db2) from the same backup (backup1.bak) which is obviously not efficient. Can someone suggest how to undo just the changes in db1 since the last restore?

PS: I'm using SQL Server 2008 R2.

Upvotes: 1

Views: 3310

Answers (2)

Michael Fredrickson
Michael Fredrickson

Reputation: 37388

After restoring your database, create a database snapshot.

To undo your changes, revert your database back to your snapshot.

This will keep you from having to hold onto your .bak file... and if your database is large relative to the amount of changes you'll be making to your database, this can be more efficient.

Upvotes: 2

Aaron Bertrand
Aaron Bertrand

Reputation: 280381

To revert you can simply restore the database again from the backup WITH REPLACE, RECOVERY.

Upvotes: 0

Related Questions