2 tables, same database
balance
Posts: 11
(I've posted this a few weeks ago, but never heard back)
Is it possible to synchronize data from 2 tables (that have the same schema) in a single DB? If so, what steps would I take?
Thanks
Is it possible to synchronize data from 2 tables (that have the same schema) in a single DB? If so, what steps would I take?
Thanks
Comments
Very simple. What you do is open a new comparison project, and specify the two databases to be the same exact database on the left as the right. Now go into mappings, and unmap the two tables that you want to cross-compare. Then map table A to table B by selecting table A on the right and table B on the left. Now table A’s data will be compared to table B’s data in the same database.
// Create the mappings between a certain table
TableMapping tableMapping = (TableMapping)mappings.Join(db1.Tables["[dbo].[Widgets]"], db2.Tables["[dbo].[Widgets2]"]);
// Set the custom comparison key for the table
tableMapping.MatchingMappings.Clear();
tableMapping.MatchingMappings.Add(tableMapping.FieldMappings["RecordID"]);
tableMapping.RefreshMappingStatus();