What are the challenges you face when working across database platforms? Take the survey

Alter instead of drop and recreate

Is there a way to force SQL Change Automation to use alter instead of drop and recreate when renaming a table? I don't want to lose the data in the table.

Best Answer

  • Options
    way0utwestway0utwest Posts: 313 Rose Gold 1
    Not directly. The tools work by looking for changes, and there isn't a way to detect that this is a rename v a drop and add, at least not easily. When you import the migration script, that is the time to change this. I'd take this script:

    And edit it to be this:

    As a side note, renaming objects is an anti-pattern that you should avoid where possible. That being said, it is necessary sometimes. While SQL Prompt has a smart rename to find references and ensure things are renamed, for tables/columns, you need to manually fix the migration script.


Sign In or Register to comment.