Refactoring «Move Columns»

Migrate table column(s), with all of its data, to another existing table.

There are two main reasons to apply Move Columns. They are may appear contradictory, but remember that database refactoring is situational.

Common motivations to apply Move Columns include the following:

  • Normalization. It is common that an existing column breaks one of the rules of normalization. By moving the column to another table, you can increase the normalization of the source table and thereby reduce data redundancy within your database.

  • Denormalization to reduce common joins. It is quite common to discover that a table is included in a join simply to gain access to a single column. You can improve performance by removing the need to perform this join by moving the column into the other table.

To apply Move Column, you need to do the following:

  1. Select table in the Object Explorer

  2. Right click on the selected table and then choose SQL Refactor Studio -> Move Columns… menu command.

  3. Select the destination table to which you want to transfer any column. Please note, the source and the destination tables must be associated by foreign key constraint.

  4. Move columns from the source table to the target one and then press the Next button.

  5. Select the foreign key constraint (available if tables are related more than one foreign key)

  6. Press Finish button to generate the SQL script.

  7. Modify generated script if you need and then press the F5 to create objects.