I’ve been working on setting up an automated drop and create for a test database for a project I’m working on. I’m trying to improve the integration testing by always starting with a consistent state.
To do this, I am trying to get an exact snapshot of the database at a certain point in time as the base point. To do this in the full version of SQL Server Management Studio 2008 is quite easy.
- Right click on the database name
- Go to Tasks > Generate Scripts
- Go through the wizard, but when you get to the ‘Choose Script Options’ page, make sure you select ‘Script Data’ to true under Table/View Options
Go through the rest of the wizard and the script file will be created for you to work with.
Thanks to Mike Ritacco on Stack Overflow for this information.