Not Executing Drop Tables in the destination database

imohammdimohammd Posts: 6
edited December 22, 2006 12:56AM in SQL Toolkit Previous Versions
I created an app to compare 2 databases (db1, db2). I want to compare the db1 with db2 and push all the changes to db2 except dropping objects. For example, if db2 has a table that is not present in the db1 database, after the sync I still want to have that table in db2.

Any help is greatly appreciated.



  • Brian DonahueBrian Donahue Posts: 6,590 New member
    Hi Imran,

    The idea is to change the selected property for the object:
             Database db1=new Database(); 
             Database db2=new Database(); 
             Differences differences=db1.CompareWith(db2, Options.Default); 
             foreach (Difference difference in differences) 
                if (difference.ObjectIn2==null) difference.Selected=false; 
                else difference.Selected=true;
    This will not include any objects that don't exist in database 2 in the synchronization.
  • Hi Brian

    Thanks a lot for the reply. That helped
    I have another issue.

    We have around 200 databases and one master database. Any new database changes are applied to this master database and I want to push these changes to all the 200 databases.

    I created a console application by following the "SQLCompareCodeSnippets" Sample application. which will compare each database with the master database. Can I show the status in percentage for the whole process. I tried using the function GetFeedback() provided in the sample app. But this shows the status for only the current compare and not the entire compare and sync.

    Also can I write all the sql script generated for all the 200 databases to a single file.

  • Brian DonahueBrian Donahue Posts: 6,590 New member
    Hi Imran,

    You can find a discussion about that here: ... php?t=2837
  • fordc03fordc03 Posts: 49 Bronze 2

    1st, create a snapshot of your master database once the changes are applied to it.

    you can do that easy enough with the command line utility. or follow the example in the toolkit help file.

    2nd, in your console app, you'll need to supply a list of databases by either querying SQL Server for it and storing it in an array or List<t> of some sort and then iterating through it.

    before going into the loop register your snapshot.

    in your loop, just register the target database and sync objects.

    you should be able to create an event or delegate easy enough in your loop to monitor the total number of databases complete.

    so you'd have two progress points...Red Gates and your own... Red gates will tell you how far the database is done to being complete and your own telling you how far along in the process you are from being done...

    I don't have the code readily available at the moment, but if you need help just ask Brian... he knows everything. :)

    j/k let me know if any of the above is confusing.
Sign In or Register to comment.