I have been exploring some of the features of Visual Studio 2010 that are useful to DBAs and Database Developers. Today’s topic is Database Deployment. Software developers have been using the deployment tools in Visual Studio for some time, however, the addition of database deployment gives database professionals the ability to systematically deploy their projects to a multiple environments.
Every enviornment can be configured to have a different configuration. For example, in my development environment I tell VS2010 to build the solution script and then deploy it to the server. In my production environment I tightly control what and when scripts are deployed to the database. When I am building the solution for my production environment I configure VS2010 to build the deployment script and put it into a folder. This allows me to schedule the script to go into production when I choose.
We are going to walk through setting up a database project and configuring the project for deployment. Open or create a database project. Right click on the top of the project in the solution explorer, at the top of the explorer tree. Select ‘Properties’ from the menu. This will open the project properties window. The deploy tab of the project properties will allow us to configure the deploy settings.

There are three main settings that we will focus on. The first is the configuration. Configuration is the setting that allows us to change the behavior for different environments. In this example project I have set the configuration to be debug. The debug configuration is my test environment and where I want to allow VS2010 to automatically deploy the solution to the server automatically.
The second setting we are going to look at is the ‘Deploy Action’. The default setting is ‘Create Deployment Script (.sql). Leaving this set on the default means that a deployment .sql script will be crated but not deployed to my database. This gives database professionals the flexibility to deploy the script via SSMS, scheduled job, etc. In the case of my test environment I want to use ‘Create a deployment script (.sql) and deploy to the database’. This will run the deployment script against my test environment every time I select deploy from the build menu.
The final setting that I want to highlight is the Target Connection Setting. This can be different with each configuration setting allowing me to connect to different SQL Servers and/or different databases for the environment I am deploying to.
What have your experiences with deployment in Visual Studio 2010. We would love to hear about them.


Pingback: Tweets that mention Database Deployment with Visual Studio 2010 | Jonathan Gardner -- Topsy.com
Pingback: Running Visual Studio 2010 Generated Deployment Scripts in SSMS