Wednesday, February 2, 2011

[General-Dev]–Generate INSERT scripts for a whole database in SQL Server Management Studio

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.

  1. Right click on the database name
  2. Go to Tasks > Generate Scripts
  3. 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

image

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.

No comments: