How to exclude tables of target database before sync?

compviscompvis Posts: 13
Hi,

I want to update data from database A (source) to database B(destination). I mean, not update data from B to A. How can i use code to exclude (custom) rows from B (target) before synchronizing data ? Like SQL Data Compare 8 software, please see image below:

Synchronization.png

Thanks

Comments

  • Hi there,

    Thanks for your post. This is actually quite simple. You need to supply a SessionSetting to the CompareDatabases method. e.g.
    m_Session.CompareDatabases(db1, db2, mappings, SessionSettings.Default ^ SessionSettings.IncludeRecordsInTwo);
    

    This will sync all rows, but remove the records that only exist in the target from the synchronization. i.e. It won't script any deletes.

    HTH!

    Pete
    Peter Peart
    Red Gate Software Ltd
    +44 (0)870 160 0037 ext. 8569
    1 866 RED GATE ext. 8569
  • Thanks,

    My example above is only one table on target. Assuming that i have two tables on target. How can i custom to select one of two tables ? With your code:

    m_Session.CompareDatabases(db1, db2, mappings, SessionSettings.Default ^ SessionSettings.IncludeRecordsInTwo);

    It means, i have to exclude all table from targets ?

    Btw: the StatusEventHandler works fine with console samples but It doesn't work with winforms (i add a progress control to display pecentages). If possible, please upload a winform sample that successfully use StatusEventHandler and progress control.

    Thanks for the best tools !
Sign In or Register to comment.