Options

Register a script file containing INSERTS to compare

thecodeslingerthecodeslinger Posts: 2
edited December 29, 2014 8:06PM in SQL Comparison SDK 11
My intent is to compare schema and data between 2 script folders generated by Microsoft's SQL Server Data Tools (SSDT). I got the idea from http://assets.red-gate.com/products/sql-development/sql-source-control/learn-more/assets/redgate-tools-and-db-projects.pdf. Note that there is no redgate xml file generated that lists what tables have static data because I used SSDT.

The schema comparison works. However, when I RegisterForDataCompare() I can't tell if it is picking up the file in the script folder that contains INSERTS (Script.PostDeployment1.sql). Also, I tried using AddDataFileWritten("Script.PostDeployment1.sql") but that did not appear to help. How can I do this? Thanks for help.

Here is a code snippet
                var scriptDatabaseInformation = new RedGate.SQLCompare.Engine.ReadFromFolder.ScriptDatabaseInformation();
                scriptDatabaseInformation.AddDataFileWritten(sourceDBLocation + @"Script.PostDeployment1.sql");

                //register databases to compare from source control
                Console.WriteLine("Registering database " + sourceDBLocation);
                sourceDB.RegisterForDataCompare(sourceDBLocation, scriptDatabaseInformation, Options.Default);

                Console.WriteLine("Registering database " + targetDBLocation);
                targetDB.RegisterForDataCompare(targetDBLocation, new RedGate.SQLCompare.Engine.ReadFromFolder.ScriptDatabaseInformation(), Options.Default);

               
                //compare data
                SchemaMappings mappings = new SchemaMappings();
                ComparisonSession session = new ComparisonSession();
                session.CompareDatabases(sourceDB, targetDB, mappings);
                //session.CompareDatabases(targetDB, sourceDB, mappings);

                SqlProvider sqlProvider = new SqlProvider();
                bool runOnTargetDB = false;
                ExecutionBlock executionBlock = sqlProvider.GetMigrationSQL(session, runOnTargetDB);

                Console.WriteLine("SQL to synchronize:");
                Console.WriteLine(executionBlock.GetString());

Sign In or Register to comment.