Coach
Coach

Reputation: 21

Deploying Database Project

lots of confusion for me while handling the VS Database Project. Okay, while trying to deploy the DB Project to a target database, the objects (SPs, Triggers) still refer to the previous database if included the reference of the same database in the objects. For example:

I have an SP which contains one of its table reference as DBName..TableName. After I deploy my project to a target database with a new name, the object still refers to the same DB which is DBName. Now to make my deployment work I change this hardcoded name to $(DBName) variable and this is passed along as the variable while deploying the Databases to the target DB. This gives an error while deployment. So can we deploy the database project containing cross references or references to the same DB to the new database target and get these names changed altogether.

Upvotes: 0

Views: 198

Answers (1)

Marko
Marko

Reputation: 93

Just try the "Publish..." Command from the Database Project Property Menu (right click on the project in solution explorer). Once the dialog is open you can set the values for your variables (e.g. [$(MyDatabase)]. If you choose the "Create publish script"-Option, a script will be generated containing SQLCMD-Variables which can be set to your target database.

Upvotes: 1

Related Questions