Running Database Project Deploy Script In SQL Management Studio

Visual Studio Database Projects is a great way to manage and maintain your SQL server database schema.  The projects offer compile time checking just like any other code type project would.  When you build build the project you have the options of either creating a deployment script or a script plus deploy it to a given database instance.  If you create the script, there is one caveat that I find myself forgetting the first time I run it via SQL Management Studio, setting the SQL command mode.  This is necessary to resolve the lines that start with “:”, such as “:setvar”.  To enable the script to run successfully, open the menu Tools ^ Options.  Click the “Query Execution” in the list.  Check the “By default, open new queries in SQLCMD mode”.  Open a new query window and run your script.


No comments: