Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

Open source tool simplifies database synchronization for SQL Server

A free tool for Microsoft SQL Server could help take the time out of syncing up public and development databases.

I don't think I've ever worked on just one copy of a given database at a time, especially for a public-facing project....

There has always been at least two copies -- the public version and whatever iterations I've used privately for development and testing. Keeping the schemas for the two in sync was usually something I did by hand, if only because I was used to doing so. Old habits die very hard indeed.

I've since come across a tool that could help make this part of the job much less tedious. It's called OpenDBDiff, a free open source database schema synchronization tool for SQL Server that's hosted on Microsoft's CodePlex website. It is GPLv2 licensed, which means you can use it internally for whatever you want. You can also redistribute the unchanged version of it as you like, but any changes you make to a redistributed version have to be published. The program doesn't need to be formally installed; you can unpack the binaries and support files into any folder and run them from there.

More tools and utilities for Microsoft SQL Server

SQL injection tools for automated testing

String manipulation basics for SQL Server

SQL Server tools guide

OpenDBDiff works by comparing the schemas of any two databases, noting the differences, and generating a synchronization script. The two databases do not have to be hosted on the same instance of SQL Server or even reside on the same computer; if you can connect to the database over the network, then you can sync to or from it. Each conversion scenario can be saved as a project file and filtered by object type, compared with case sensitivity either on or off, and constrained with a number of other parameters. The generated change script can then be copied out and run at your leisure, so it's not possible to accidentally trash a database schema with this program.

Note that the documentation for the program is pretty skimpy—as in, there's barely any at all. It took some trial and error (and studying of screenshots) before I realized the Server Host field for the source and destination databases needs to be filled out in the format SERVERNAME\INSTANCENAME. In other words, if you have a computer named MYSERVER and a SQL Server instance named SQLEXPRESS, you'd use MYSERVER\SQLEXPRESS to connect to it. For me, a more intelligent bit of user interface design would be to place the host and instance names in separate boxes.

Another version of the project also exists, dubbed sql-dbdiff. That one is GPLv3 licensed, and sports some extra capabilities. One example is a feature called Visual Diff that shows the changes between the create script for the old and new versions of a given object. This version of the program is also being developed a little more quickly, so it's probably the better of the two (even if it isn't the original).

Figure 1. OpenDBDiff in its sql-dbdiff variant (click to enlarge)

Serdar Yegulalp has been writing about computers and information technology for more than 15 years for a variety of publications, including InformationWeek and Windows Magazine.


This was last published in March 2010

Dig Deeper on SQL Server Database Modeling and Design

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.