Simple Merges KDiff3 at SQL in the City

One of the hassles of working in a development team is that you will have conflicts between your code and another developer’s. That’s fine, and it’s a natural effect of allowing each person to work on parts of a database independently.

However resolving conflicts can be a pain. Fortunately there are some nice utilities that can help make the process easier. 

If you want to see this live, come to SQL in the City 2015 in London or Seattle this October.

Here’s a quick example. I was simulating two developers, each with their own database, but linked to a common Git VCS repository. I went to commit a change and got this:

2015-08-19 16_36_42-New notification

SQL Source Control detects a conflict before committing the stored procedure on the left. As you can see, it has more fields in it, while the version in my VCS has a TOP clause. I can keep my version or update mine with what’s in VCS.

Or, if you look to the right, you can see I have the option to “Merge” code. If I click Merge, then I’ll open KDiff3, which is installed on my system. SQL Source Control has detected this and given me the chance to resolve the issue.


I get a message that there are 3 conflicts, and none of them could be resolved. If there are places where the code can be merged automatically, KDiff3 will do that.

Once I acknowledge this, I see my code. This looks like what I saw in SQL Source Control. My code is on the left, and the version from VCS is on the right. Below is the merged code, which has some placeholders where the code conflicts.

2015-08-19 16_37_28-Your file _-_ Their file - KDiff3

If I right click the first conflict, I get some choices. In this case, I’ll take the line from the left, which has no TOP clause.

2015-08-19 16_37_38-Cortana

This gets inserted into my code and I can move on to the second conflict. In this case, I’ll take the version on the right, which has nothing.

2015-08-19 16_37_58-Your file _-_ Their file - KDiff3

For the last conflict, I’ll also take the missing fields from the right.

2015-08-19 16_38_19-Your file _-_ Their file - KDiff3

If I now save and close KDiff3, I’ll get the merged code in SSMS and SQL Source Control.

2015-08-19 16_38_32-New notification

Not the “Keep mine” is selected. I’ll commit this, which will be the most up to date version in our VCS. Other developers can update their code with this version, and if they have conflicts, SQL Source Control and KDiff3 make them easy (ier) to resolve.

I’ll be showing you some basics of using a VCS with your database at SQL in the City 2015 this October. You can see this and more in London on October 16 or Seattle on October 26. If you can come to either event, register today and come pick up a few tips and tricks.

About way0utwest

Editor, SQLServerCentral
This entry was posted in Blog and tagged , , , . Bookmark the permalink.