Excluding Columns before invoking CompareDatabases method
Disciple1991
Posts: 4
Is there a way to exclude specific columns from being compared before invoking the CompareDatabases method?
I understand how to exclude Tables and I know that the GUI tool allows you to exclude columns from the DataCompare. I am assuming I can create a Table.Fields collection and just Add the columns I want to compare but have been unsuccessful in finding any help.
Thanks for any help.
//create an intersection of the tables
Tables commonTables=Tables.CreateFromIntersection(db1.Tables, db2.Tables);
//set up the table comparison setting
TableComparisonSettings settings=new TableComparisonSettings();
foreach (Table table in commonTables)
{
settings.Add(new TableComparisonSetting(table.FullyQualifiedName, table.Fields, table.PrimaryKey.Fields));
}
session.CompareDatabases(db1, db2, settings);
I understand how to exclude Tables and I know that the GUI tool allows you to exclude columns from the DataCompare. I am assuming I can create a Table.Fields collection and just Add the columns I want to compare but have been unsuccessful in finding any help.
Thanks for any help.
//create an intersection of the tables
Tables commonTables=Tables.CreateFromIntersection(db1.Tables, db2.Tables);
//set up the table comparison setting
TableComparisonSettings settings=new TableComparisonSettings();
foreach (Table table in commonTables)
{
settings.Add(new TableComparisonSetting(table.FullyQualifiedName, table.Fields, table.PrimaryKey.Fields));
}
session.CompareDatabases(db1, db2, settings);
Comments
Also to answer your question you will need to create your own intersection
as you can't as you've noticed remove a field from the Fields collection.
In your foreach loop I think you'll want something like the following...
If you look in your start menu in Red Gate there should be an entry for the help file 'The SQL Comparison and Synchronisation Toolkit' all the reference documentation is in there.
Project Manager
Red Gate Software Ltd