Ignore Custom db Objects

Automate and integrate using the SQL comparison API

Moderator: Chris Auckland

Ignore Custom db Objects

Postby IndyNotesGuy » Sat Sep 27, 2008 11:10 am

Ok I am stumped, here is what I am trying to do:

We have a database based off another vendors schema, we take that orginial schema and add custom tables, stored procedures, functions, etc. I am trying to build a project to re-sync the core back to the orginial schema, I do not however want to drop any of the custom items we may have added.

I just want to drop any custom indexes we may have placed on the orginial database tables, and then add any new db objects the vendors database now has.

I have played with a foreach loop, looping through the differences and excluding objects which only exists in Production database, but that excludes any custom indexes we may have added.

So basically I just want to compare items that exist in both schema, what am I missing?

Thanks.
IndyNotesGuy
 
Posts: 1
Joined: Sat Sep 27, 2008 10:39 am
Location: Indianapolis, IN

Postby eddie davis » Tue Sep 30, 2008 5:04 pm

Thank you for your post into the forum.

To achieve the results you are looking for you will need to perform two comparison and synchronizations.

The first comparison and synchronization you need to use the Ignore Indexes option.
Code: Select all
            Database db1=new Database();
            Database db2=new Database();
             
            db1.Register(new ConnectionProperties(".", "WidgetStaging"), Options.Default);
            db2.Register(new ConnectionProperties(".", "WidgetProduction"), Options.Default);
             
            Differences differences=db1.CompareWith(db2, Options.Default | Options.IgnoreIndexes); //Using the default options and the Ignore Indexes option
             
            foreach (Difference difference in differences)
            {
                Console.WriteLine("{0} {1} {2}", difference.Type.ToString(), difference.DatabaseObjectType.ToString(), difference.Name);
            }
             
            //dispose of the objects
            db1.Dispose();
            db2.Dispose();


As the Ignore Indexes will also remove any indexes you have set on your new custom tables.

Perform another Comparison and Synchronization and only include the new custom tables with the Ignore Indexes removed. When the synchronization is run it will add the indexes you configured for the new tables.

Many Thanks
Eddie
Eddie Davis
Technical Support Engineer
Red Gate Software Ltd
E-mail: support@red-gate.com
eddie davis
 
Posts: 943
Joined: Wed Jun 14, 2006 3:47 pm
Location: Red Gate Software


Return to SQL Comparison SDK Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests