Comparing SnapShot With Live Database

Pascal_GirardPascal_Girard Posts: 5
edited January 24, 2008 6:11AM in SQL Compare Previous Versions
I trying to compare my live database with snapshot with this code.

When i loop thru the difference my options is not apply. All table with not for replication statement appears.



Options cmpOption = Options.IgnorePermissions | Options.IgnorePermissions | Options.IgnoreUsers | Options.IgnoreWhiteSpace | Options.IgnoreUserProperties | Options.IgnoreCollations | Options.IgnoreNotForReplication;
RedGate.SQLCompare.Engine.Database db = new RedGate.SQLCompare.Engine.Database();
RedGate.SQLCompare.Engine.Database dbSnapShot = new RedGate.SQLCompare.Engine.Database();
//Set eventHandler to get the status
db.Status += new RedGate.SQL.Shared.StatusEventHandler(StatusCallback);
trace.WriteTrace(Text.TraceLoadDataBase + config.Server + "\\" + config.Name);
db.Register(new ConnectionProperties(config.Server, config.Name, config.UserId, config.Password), cmpOption);
trace.WriteTrace(Text.TraceLoadSnapShot + snapshot);

Differences differences = dbSnapShot.CompareWith(db, cmpOption);
foreach (Difference difference in differences)
//make sure the difference is selected so it is included in the synchronization
difference.Selected = true;

Work work = new Work();
work.Status += new RedGate.SQL.Shared.StatusEventHandler(StatusCallback);
//calculate the work to do using options
work.BuildFromDifferences(differences, cmpOption, true);
RedGate.SQL.Shared.ExecutionBlock block = work.ExecutionBlock;

//and run the SQL
RedGate.SQL.Shared.BlockExecutor executor = new RedGate.SQL.Shared.BlockExecutor();
executor.ExecuteBlock(block, config.Server, config.Name,false ,config.UserId, config.Password);
executor.Status += new RedGate.SQL.Shared.StatusEventHandler(StatusCallback);
//dispose of the objects

//dispose of the objects


  • The 'Options.IgnoreNotForReplication' option ignores differences in tables which are caused only by the presence or absence of the Not For Replication option on table elements.

    The tables will still appear in the Differences collection (which holds all objects whether they are equal or not - equal objects just have a Type field set to DifferenceType.Equal), and if they have some other difference on them as well as the Not For Replication difference they will still be synchronized.

    Does that help with your problem?
    Software Developer
    Redgate Software
Sign In or Register to comment.