Merging two databases using the Toolkit

paulchapmanpaulchapman Posts: 4

We are currently using the SQL bundle 5. We use SQL Compare and SQL Data Compare to update 'local' databases from a central database.

At the start of a session the user's local db gets compared with the master db and changes applied to the local db.

At the end of the session, the users db is compared with the master db and changes applied to the master db.

We have configured custom index mappings for the comparison which appear to be working correctly.
This is all done using the API in C# VS2003.NET.

The problem is that the databases aren't merged correctly. When the changes to be made are scripted, there are DELETE statements. Is there any way to supress the DELETE's?

Has anybody get any pseudo code/code samples that shows how to programmatically merge 2 db's?

Thanks in advance,



  • Options
    Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hi Paul,

    Thanks for the question. To stop data from being deleted during a data synchronization using SQL Toolkit's Data Compare Engine, use the SessionSettings enumeration. Setting IncludeRecordsIn1 and not IncludeRecordsIn2, for instance, will stop DELETE queries from getting scripted against db2. The SessionSettings need to be used in the comparedatabases() method:

    Database db1=new Database();
    Database2=new Database();
    db1.RegisterForDataCompare(new ConnectionProperties(".","BRIAN"));
    db2.RegisterForDataCompare(new ConnectionProperties(".","NEWBRIAN"));
    SessionSettings settings=SessionSettings.IncludeDifferentRecords | SessionSettings.IncludeRecordsInOne;
    ComparisonSession cs=new ComparisonSession();
    SchemaMappings m=new SchemaMappings();
    m.CreateMappings(db1, db2);

    This should hopefully point you in the right direction.
Sign In or Register to comment.