Change Script check if exists

Hello,

When generating a change script, there is no safeguard to check if the affected object already exists or not.
Is there an option I can set so it does a check before executing the change?

I understand I can add the check my self, but I'm kind of lazy you know ;)

Eric
Tagged:

Best Answers

  • Sergio RSergio R Posts: 520 Rose Gold 4
    edited March 27, 2020 4:23PM Accepted Answer
    Hi,

    In SQL Change  Automation for SSMS, after you generate the script you can verify it, this verification will fail if you have duplicate objects.

    There's also a drift check when you create a release using SQL Change Automation Powershell, which produces a drift report.
    Sergio
    Product Support Engineer
    Redgate Software Ltd
    Please see our Help Center for detailed guides on how to use our tools
  • Sergio RSergio R Posts: 520 Rose Gold 4
    Accepted Answer
    To complement my previous answer if you ensure that your targets are only updated from SQL Change Automation you shouldn't run into any issues.

    There's also a Comparison option which adds existence checks if you generate the script by capturing it from the development database: 
    <!-- "Add object existence checks" SQL Compare option -->
    <SyncOptionIncludeExistenceChecks>False</SyncOptionIncludeExistenceChecks>

    https://documentation.red-gate.com/sca/developing-databases/concepts/advanced-concepts/comparison-and-script-generation-options

    Sergio
    Product Support Engineer
    Redgate Software Ltd
    Please see our Help Center for detailed guides on how to use our tools

Answers

Sign In or Register to comment.