SQL Source Control 7

Merging branches

If you're working with migration scripts, merge using your source control system. To resolve conflicts that involve migration scripts, see Resolving conflicts.

SQL Source Control doesn't provide automatic or line-by-line merging. You can use SQL Source Control or SQL Compare to merge at an object level, but not choose line-by-line changes.

When you merge with SQL Source Control or SQL Compare, you choose a version of each object to keep. For example, you might keep the master version of a table and the branch version of a view.

There are three different approaches to merging.

Merging using your source control system

We recommend this approach if the merge is complex, or if there are conflicts; for example, if the same object has been modified in both the branch and master.

You can manually merge the branch changes back into master using your version control system. As you would for application code, make sure references between objects remain valid after merging.

Merging using SQL Source Control

If you don't need to do a line-by-line merge, you can merge with SQL Source Control.

To merge branch changes back into master with SQL Source Control:

  1. In SQL Source Control, make sure you have a database linked to the branch in your source control repository.
  2. Get the latest version and commit any outstanding changes.
  3. Unlink the database from the branch.
  4. Relink the database to master.
  5. Go to the Commit tab.
    The tab shows the changes to the branch as changes to commit.
    If there are conflicts, choose Keep mine to override master with the objects from the branch.
  6. Commit the changes.

    Master is updated with the branch changes.

Merging using SQL Compare

If there are no conflicting changes between the branch and master, you can merge automatically using SQL Compare.

To merge branch changes into master with SQL Compare:

  1. In SQL Source Control, make sure you have a database linked to master.
  2. Use your source control system to create a local copy of the latest branch version, for example by performing an SVN checkout.
  3. In SQL Compare, create a new project. Set the local copy of the branch as the source, and the database linked to master as the target.
    For more information, see Setting data sources.
  4. Compare the data sources.

    SQL Compare shows the differences between the branch and master.

  5. In the Results pane, select the objects from the branch that you want to merge into master. Then, run the Deployment Wizard to deploy from the data source to the target.
    Master is updated with the changes from the branch.
  6. In SQL Source Control, on the Commit tab, commit changes from master to source control.

Didn't find what you were looking for?