SQL Comparison SDK™
Walk-through: Using Red Gate APIs
This walk-through will show you:
- Using the SQL Compare API to automate comparison and synchronization tasks
- Features in the SQL Comparison SDK
- Building your application
Stop walk-through
Step 6: Comparing databases
After registering your databases, the next step is to compare them. We do this by using the CompareWith method:
Differences differences=db1.CompareWith(db2, Options.Default);
This returns a differences collection which contains a summary of the differences between the two databases. We can loop through this collection and print out the summary to screen:
foreach (Difference d in differences) { Console.WriteLine("{0} {1} {2}", d.Type.ToString(), DatabaseObjectType.ToString(), d.Name); d.Selected=true; }
We also set the selected property to true to indicate that we want to use each difference, in the script we are going to generate in the next step.

