Specifying table before comparing

mtranmtran Posts: 34
edited October 8, 2008 12:39PM in SQL Compare Previous Versions
To decrease the time it takes to compare, is there a way to specify which objects to compare before running the comparison on the database? For example, I would like to compare the table "TBL" between two databases without having to compare the whole database first. I know for SQL Data Compare you have mappings, but I would like to compare the structure and not the data.

Thanks

Comments

  • Hi,

    Sorry, we don't have this feature in the GUI version yet. The command line version (available in the pro edition) lets you filter by object type and object name (see http://www.red-gate.com/MessageBoard/vi ... php?t=7845 for an example).

    Can I ask why you don't want to compare the entire database?

    Kind regards,

    David Atkinson
    Red Gate Software
    David Atkinson
    Product Manager
    Redgate Software
  • Sorry I was referring to the API. We need to move certain tables from one database to another and we already know which tables need to be moved.
  • Currently you can't register anything less than the whole database, and that's not likely to change in the future. The reason for this is dependencies - if we haven't registered the whole database we don't know what might depend on those tables you're trying to move, and so we can't be sure that it's safe to move them without also moving associated views, stored procedures etc etc that might rely on some element of the table that's changing.
    Software Developer
    Redgate Software
  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Once you have compared the database schemata, you can then select which objects will appear in the script, if that helps. You can do this by looping through all of the DatabaseDifferences and and setting the "Selected" property to "true" or "false" depending on the conditions you set. So what you could do is loop through the database differences and set all of them to not be selected unless they meet the condition that the DatabaseObjectType is "table" and the name matches one in the list of names of tables that you want to migrate.

    I hope this helps!
  • To add to this, here is a small code sample to demonstrate Brian's post. (Based on our SQL Compare API sample project)
    // Display the results on the console
                    foreach (Difference difference in stagingVsProduction)   
                    {
                        if (difference.Name == "<object name>")
                        {
                            Console.WriteLine("{0} {1} {2}", difference.Type, difference.DatabaseObjectType, difference.Name);
                            difference.Selected = true; 
                        }
                    }
    
    Chris
Sign In or Register to comment.