Reputation: 332
For testing purposes I would like to reset a complete database to a certain state (data and structure). I would like to do this automated. Preferably a command line instruction before I start my tests.
After some searching I discovered that SQL Server offers an great solution for this. Snapshots. After writing a test query I discovered that the standard edition of SQL Server does NOT support this. :-(
Given the fact that I want this to be automated: what are my options? Overwriting the data files immediately doesn't sound like a good option to me...
Some other information:
Thank you in advance!
Upvotes: 10
Views: 8625
Reputation: 33914
I homebrewed a solution like this because I wasn't happy with the way replication was running (and I was also using standard edition) - maybe my solution will lead you in the right direction:
Basically, it takes a periodic backup, zips it, FTPs it somewhere, and the remote server checks for new files, extracts them, restores them, and then emails you to let you know a new replica has been restored.
Upvotes: 3
Reputation: 17080
For testing, you can use Developers Edition, which has snapshots and is quite cheap. However, we prefer to build a new test database from scripts in source control - that allows us to easily determine the changes, quickly roll out a testing system on any box, and saves us a lot of time.
Upvotes: 1
Reputation: 239664
If you're doing this for testing purposes, you can use Developer Edition:
SQL Server 2008 Developer includes all of the functionality of Enterprise Edition, but is licensed only for development, test, and demo use.
Upvotes: 6
Reputation: 35613
Detach the MDF file, copy it somewhere, re-attach it.
When you want to reset the database, detatch the MDF, copy the old one over the top, and re-attach it.
Alternatively backup and restore.
Upvotes: 6