SQL Database Project: build different scripts depending on build configuration

前端 未结 2 1224
渐次进展
渐次进展 2021-01-03 03:10

The problem I want to solve is to build different scripts depending on build configuration.

Say we have two instances of SQL Server:

  • Enterprise version
相关标签:
2条回答
  • 2021-01-03 03:40

    You may have another possible option in using composite projects. Jamie Thompson blogged about them here: http://sqlblog.com/blogs/jamie_thomson/archive/2013/03/10/deployment-of-client-specific-database-code-using-ssdt.aspx

    This would let you build a main project and tie in additional projects with the environment-specific code. You could deploy the appropriate one by doing some checks in the release scripts.

    0 讨论(0)
  • 2021-01-03 04:01

    I was thinking about this and the best way to handle it with SSDT. I probably don't have a "best" way, but if you can determine the correct version prior to publishing your changes, I'd consider this:

    1. Create a publish profile for each edition - with and without linked servers.
    2. Create variables to hold your linked server names, possibly including the database as well so something like "[Server].[Database]."
    3. Create a post-deploy script for your linked server views. These should include permissions, the variables for the linked server names, and so on.
    4. In the Post-Deploy script, query your "edition" variable. If it will use linked servers, drop/recreate the native non-linked server views in the project to use the ones on the linked servers. Alternatively, set the variable to an empty string for the local view and to the server/DB for the linked server and you can probably just use one set of code.

    This has the disadvantage of not being able to code-check your views, but would give you one place to store those linked server views and one place from which to deploy them. You'd need to release with a Drop/Create instead of letting SSDT handle the changes which means they would be re-created on each Publish action. I think it might give you the solution you're seeking, though.

    0 讨论(0)
提交回复
热议问题