How to exclude tables of target database before sync?

Automate and integrate using the SQL comparison API

Moderator: Chris Auckland

How to exclude tables of target database before sync?

Postby compvis » Mon Aug 02, 2010 8:18 am

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:

Image

Thanks
compvis
 
Posts: 9
Joined: Mon Aug 02, 2010 7:43 am

Postby peter.peart » Tue Aug 03, 2010 5:08 pm

Hi there,

Thanks for your post. This is actually quite simple. You need to supply a SessionSetting to the CompareDatabases method. e.g.

Code: Select all
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
peter.peart
Site Admin
 
Posts: 362
Joined: Tue Sep 02, 2008 9:58 am
Location: Top floor, RG towers with the cool kids

Postby compvis » Wed Aug 04, 2010 2:09 am

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 !
compvis
 
Posts: 9
Joined: Mon Aug 02, 2010 7:43 am


Return to SQL Comparison SDK Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests