How to: Prepare Database Build Scripts
After you change the database project, you must prepare the build script to either create or update the target. You specify a new or existing database as the target by configuring build settings in the project properties. After you configure those settings, you can build the database project, which assembles any pre-deployment and post-deployment scripts together with the object definitions from the database project. After you prepare the database build script, you can deploy it to the target's database server.
To prepare a database build script in Visual Studio
In Solution Explorer, click the node for the database project for which you want to prepare a build script.
On the Build menu, click Build DatabaseProject.
The object definition scripts and pre-deployment and post-deployment scripts are assembled.
To prepare a database build script from the command line
Open the Command Prompt window, and browse to your project directory.
By default, projects are created in My Documents/Visual Studio 2008/Projects.
At the command prompt, type the following command line to generate a build script where DatabaseProject is the name of your project:
MSBuild /t:Build Path\DatabaseProject.dbproj
MSBuild.exe must be on the path that your PATH environment variable specifies. In addition, the name of the target database must be set either in the database project or as part of the command line. If you are generating an update script, you must also specify the TargetConnectionString. For more information about command line syntax for generating build scripts, see An Overview of Database Build and Deployment.
The object definition scripts and pre-deployment and post-deployment scripts are assembled. If you are preparing an update script, the target connection that you specified in the build settings determines what updates you must have in order to synchronize the target with the database project. Results such as the following appear:
------ Build started: Project: ProjectName, Configuration: Debug Any CPU ------
Verifying project state.
Finished verifying project state.
ProjectName -> ProjectDrive:\Documents and Settings\UserName\My Documents\Visual Studio 2008\Projects\SolutionName\ProjectName\sql\ProjectName.dbschema
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
You can prepare a build script to create a database without having permissions on a target database or server because you do not have to access the database to build the database project for a new deployment. To prepare an update script, you must have permission to access the server, the database, and the database objects in the target.