background preloader

Diff

Facebook Twitter

Text

WinMerge. KDiff3 - Homepage. JSON Diff. A Generic, Reusable Diff Algorithm in C# - II. Free source code and programming help. Introduction During one of my daily visits to CodeProject, I ran across an excellent article by Aprenot: A Generic - Reusable Diff Algorithm in C#. Aprenot’s method of locating the Longest Common Sequence of two sequential sets of objects works extremely well on small sets. As the sets get larger, the algorithm begins experiencing the constraints of reality. At the heart of the algorithm is a table that stores the comparison results of every item in the first set to every item in the second set.

This article will present an algorithm based on the one presented by aprenot. Maintain the original concepts of Generic and Reusable. The Problem Defined Given a data set of 100,000 items, with the need to compare it to a data set of similar size, you can quickly see the problem with using a table to hold the results.

Some Terminology There are always two sets of items to compare. Generic and Reusable In order to maintain the generic aspects of the original algorithm, a generic structure is needed. SQL Server 2005 TableDiff Utility. One of the many command line utilities that came with SQL Server 2005 is the TableDiff utility. Although this utility is primarily designed for comparing replicated tables, we can take advantage of its functionality to compare tables. The objective of this article is to demonstrate the TableDiff utility.

Let us assume that we have the following databases and table. Step 1 Step 2 Go to the command prompt [Click Start – Run – Cmd.exe – press enter] and type the following commands. Note: Change the path depending on your installation configuration. Program Files\Microsoft SQL Server\90\COM folder C:\> cd "C:\Program Files\Microsoft SQL Server\90\COM" C:\Program Files\Microsoft SQL Server\90\COM>tablediff -sourceserver "SQL2005" - sourcedatabase "MyDB1" -sourcetable "ABC" -destinationserver "SQL2005" -destinat iondatabase "MyDB2" -destinationtable "ABC" Result on SQL2005 have 4 differences. Step 3 This time the TableDiff Utility also created C:\Diff.SQL file as shown below. Fig 1.1 Conclusion.

Generate synchronization scripts in SQL Server with TableDiff.