How do I programatically set the keys of a table in Data Com

ben_leahben_leah Posts: 12 Bronze 2
edited January 10, 2007 12:50PM in SQL Toolkit Previous Versions
How do I programatically set the keys of a table in Data Compare if the tables do not have any keys on them?

Comments

  • ben_leahben_leah Posts: 12 Bronze 2
    In other words, how do set a Comparison Key programatically ?
  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hello Ben,

    There is an example of this in the Toolkit Example files (tablemappingexample.cs)
    // Create the mappings between a certain table
    				TableMapping tableMapping = (TableMapping)mappings.Join(db1.Tables["[dbo].[WidgetPrices]"], db2.Tables["[dbo].[WidgetPrices]"]);
    
    				// Set the custom comparison key for the table
    				tableMapping.MatchingMappings.Clear();
    				tableMapping.MatchingMappings.Add(tableMapping.FieldMappings["WidgetID"]);
    				tableMapping.RefreshMappingStatus();
    
  • ben_leahben_leah Posts: 12 Bronze 2
    Ok, thats fine how do I then just select one other column to do the comparison on. So I only want Updates to be scripted out if only one columns has different values?
  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hello Ben,

    Then you'll want to set the 'include' property to true on the FieldMapping objects for the Fields that you want to compare and false for the ones you don't want to compare. Each TableMapping object in tableMappings should have a FieldMappings collection.
Sign In or Register to comment.