Schema Compare

rduclosrduclos Posts: 8
edited September 27, 2006 11:03AM in SQL Toolkit Previous Versions
I am trying to compare 2 databases and only script a portion of the executionblock at a time. Is there a wy to filter the execution block to only script based on if it is a Dropping|Altering|Adding script?
Thank you,
Ryan

Comments

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

    The best thing I can think of is to loop through the collection of differences that you get after using the comparewith method and set any object difference's 'Selected' property to 'false' if you do not want to script them.

    Then, when you use the work.ExecutionBlock, the differences that you feed to it in the first argument will not be scripted if the individual difference's 'selected' property is set to 'false'.
  • I was looking into this and using the difference object does not give me the SQL Script, i need the script to determine what file i need to write it to.

    I am trying to write 3 seperate files based on if they are dropping|alterining|adding.
    Thank you,
    Ryan
  • Brian DonahueBrian Donahue Posts: 6,590 New member
    Differences differences=db1.CompareWith(db2, Options.Default);
    //script only different objects
    foreach (Difference difference in differences)
    {
    if (difference.ObjectIn1!=null && difference.ObjectIn2!=null) difference.Selected=true;
    else difference.Selected=false;
    }
    work.BuildFromDifferences(differences, Options.Default, true);
    ExecutionBlock block=work.ExecutionBlock;
    Console.WriteLine(block.GetString());
    
    ...etc...
Sign In or Register to comment.