How to: Define Variables for Database Projects

You can further customize your database project by defining SETVAR variables and including them in your pre-deployment and post-deployment scripts. For example, you can define SETVAR variables for a service broker or a service certificate.

If you define a SETVAR variable in terms of an MSBuild variable, you can specify values for the MSBuild variable that are specific to a build configuration, or you can override the MSBuild variable at a command prompt when you build the database project. You cannot define a SETVAR variable in terms of another SETVAR variable. For more information about MSBuild variables, see MSBuild Properties.

Note

You can use SETVAR variables and MSBuild variables in the same scripts. However, you should not give a SETVAR variable the same name as a MSBuild variable because the MSBuild variable will take precedence.

You define SETVAR variables on the Variables tab of the properties for your database project, but you define variables for cross-database references on the References tab. For more information about cross-database references, see Overview of Cross-Database References.

To display the SETVAR variables for a database project

  1. In Solution Explorer, click the database project for which you want to display SETVAR variables.

  2. On the Project menu, click ProjectName Properties.

    The Properties window appears.

  3. Click the Variables tab.

    A list of all SETVAR variables and values for that database project appears.

To add a SETVAR variable to a database project

  1. Display the list of SETVAR variables.

    For more information, see the first procedure in this topic.

  2. Click in the Variable Name column of the last row in the list.

  3. Type a name for the variable that you want to add.

  4. Click in the Variable Value column of the row in which you just added the variable name.

  5. Type a value for the variable.

  6. On the File menu, click Save All.

To modify a SETVAR variable for a database project

  1. Display the list of SETVAR variables.

    For more information, see the first procedure in this topic.

  2. Click in the Variable Value column of the row for the variable whose value you want to change.

  3. Type the new value for the variable.

  4. On the File menu, click Save All.

To delete a SETVAR variable for a database project

  1. Display the list of SETVAR variables for a database project.

    For more information, see the first procedure in this topic.

  2. Right-click in the Variable Name column of the row for the variable that you want to delete, and click Remove Variable.

  3. On the File menu, click Save All.

See Also

Concepts

An Overview of Database Build and Deployment
Terminology Overview of Team Edition for Database Professionals

Other Resources

Overview of Files and Filegroups
How to: Add Files and Filegroups