2

In a SSDT Database project, I know how to publish the Self-Database to different locations. I can change eg, the Customer database name in the Publish profile.

Example In:

  • Dev Environment: will publish profile to CustomerDevDB

  • QA Environment: will publish profile to CustomerQADB

  • Prod Environment: will publish profile to CustomerProdDB

(This is legacy system, I did not design it like this)

Now in our Customer Database, I have stored procedures which point to a Product database reference. How do I change my Project reference to be variable for each Publish Profile?

Dev Environment: will publish to CustomerDevDB and will point to ProductDev

QA Environment: will publish to CustomerQADB and will point to ProductQA

Prod Environment: will publish to CustomerProd and will point to ProductProd

I am trying to test around with Project DB Reference, and SQL Command variables. * I can point the Database Reference to different databases names, however I cannot change the reference in the publish profile yet (which is what I am really looking for).

If someone can print screen images of how to do this, it would be helpful. Thanks

enter image description here

1

I'm not sure how to do this in the UI, however, the publish profiles are xml files, and SQL Command variables and their values can be stored within them. In this specific case, you'd want to specify the value of the $(ProductVariable) like so for your ProductDev deployment:

  <ItemGroup>
    <SqlCmdVariable Include="ProductVariable">
      <Value>ProductDev</Value>
    </SqlCmdVariable>
  </ItemGroup>

You'd add that ItemGroup to your publish profile after the </Property Group> before the </Project>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy