How can we help you today? How can we help you today?
Chris Spencer
Hi You can achieve this by setting the TableMappings.Options in the following manner: mappings.Options = new EngineDataCompareOptions( MappingOptions.Default, ComparisonOptions.Default, SqlOptions.OutputComments ^ SqlOptions.OutputCommentHeader ^ SqlOptions.Default); You can see how I'm using the above code in the following program using System; using RedGate.SQL.Shared; using RedGate.SQLCompare.Engine; using RedGate.SQLDataCompare.Engine; namespace SQLDataCompareCodeSnippets { public class SqlProviderExample { public static void Main() { RunExample(); Console.Read(); } public static void RunExample() { Database db1 = new Database(); Database db2 = new Database(); db1.RegisterForDataCompare(new ConnectionProperties(".", "Test1"), Options.Default); db2.RegisterForDataCompare(new ConnectionProperties(".", "Test2"), Options.Default); // Create the mappings between the two databases TableMappings mappings = new TableMappings(); mappings.CreateMappings(db1.Tables, db2.Tables); // //Setup options so as to exlude the comment header and general comments from the scripts // mappings.Options = new EngineDataCompareOptions( MappingOptions.Default, ComparisonOptions.Default, SqlOptions.OutputComments ^ SqlOptions.OutputCommentHeader ^ SqlOptions.Default); using (ComparisonSession session = new ComparisonSession()) { // // Remember to set up the session options // session.Options = mappings.Options; session.CompareDatabases(db1, db2, mappings); // now get the ExecutionBlock containing the SQL // we want to run this on Test2 so we pass on true as the second parameter SqlProvider provider = new SqlProvider(); // // Also rememeber to set up the provider options // provider.Options = session.Options; ExecutionBlock block; try { block = provider.GetMigrationSQL(session, true); Console.WriteLine("The synchronization SQL contains {0} lines in {1} batches", block.LineCount, block.BatchCount); // if the ExecutionBlock was very large this could cause memory problems Console.WriteLine("The SQL to be run is:"); Console.WriteLine(block.GetString()); // we can access the SQL in a memory efficient manner by accessing the underlying stream // FileStream stream=block.GetFileStream(); // run the SQL ( commented out by default ) // BlockExecutor executor = new BlockExecutor(); // executor.ExecuteBlock(block, ".", "Test2"); } finally { block = provider.Block; if (block != null) { block.Dispose(); // dispose of the objects to delete temporary files } } } db1.Dispose(); db2.Dispose(); } } } Hope this helps Chris / comments
Hi You can achieve this by setting the TableMappings.Options in the following manner:mappings.Options = new EngineDataCompareOptions( MappingOptions.Default, C...
0 votes
Hi My guess is that you've activated SQL Data Compare with a standard license. Compare to backup is a pro license only feature. Hope this helps Regards Chris / comments
Hi My guess is that you've activated SQL Data Compare with a standard license. Compare to backup is a pro license only feature. Hope this helps Regards Chris
0 votes