Comparing Table Fields

kriggskriggs Posts: 3
edited April 25, 2006 3:24PM in SQL Toolkit Previous Versions
I am trying to compare only a few fields between two databases using SQL Toolkit 4. I see how to pass in the table.fields using:
settings.Add(new TableComparisonSetting(Table.FullyQualifiedName, Table.Fields, Table.PrimaryKey.Fields));
but I can not figure out how to set the Table.Fields to a subset of the available fields in the table.
Thanks in advance for any help that may be offered.

Comments

  • I was able to answer my own question before anyone got to it. In case your interested on how to do this, here is some sample code.
    :idea:
    The code below goes through a collection of common tables and if the common table is selected for comparson creates a new table object and loops through the fields checking to ensure that they are marked for comparison and adding them to a table.Fields property of the table object, which is then passed to the New TableComparisonSettings.
    foreach (Table table in commonTables)
    {
    if (ct.m_alTables.Contains(table.Name))
    {
    Table inputTable = new Table(table.Owner, table.Name);
    IEnumerator iFields = table.Fields.GetEnumerator();
    ct.GetComparableColumns(table);
    int i = 0;
    while (iFields.MoveNext())
    {
    Field tableField = table.Fields;
    if (ct.m_alTableColumns.Contains(tableField.Name) || table.PrimaryKey.Fields.ContainsField(tableField.Name.ToString()))
    {
    inputTable.Fields.Add(tableField);
    }
    i++;
    }

    settings.Add(new TableComparisonSetting(inputTable.FullyQualifiedName, inputTable.Fields, table.PrimaryKey.Fields));
    }
    }
Sign In or Register to comment.