How to compare 2 snapshot files? snapshot file and database?
C#developer
Posts: 2
It seems that SQL Compare 5 supports such coparition and synchronization.
For comparing 2 databases I there is code:
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);
foreach (Difference difference in differences)
{
difference.Selected=true;
}
Work work=new Work();
work.BuildFromDifferences(differences, Options.Default, true);
block=work.ExecutionBlock;
RedGate.SQL.Shared.BlockExecutor executor=new RedGate.SQL.Shared.BlockExecutor();
executor.ExecuteBlock(block, ".", "WidgetProduction");
block.Dispose();
db1.Dispose();
db2.Dispose();
I need to compeare 2 snapshot files and snapshot file and database.
or just ansfer me how to register Database object from snapshot file without using SQL Server. :?:
Thank you
For comparing 2 databases I there is code:
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);
foreach (Difference difference in differences)
{
difference.Selected=true;
}
Work work=new Work();
work.BuildFromDifferences(differences, Options.Default, true);
block=work.ExecutionBlock;
RedGate.SQL.Shared.BlockExecutor executor=new RedGate.SQL.Shared.BlockExecutor();
executor.ExecuteBlock(block, ".", "WidgetProduction");
block.Dispose();
db1.Dispose();
db2.Dispose();
I need to compeare 2 snapshot files and snapshot file and database.
or just ansfer me how to register Database object from snapshot file without using SQL Server. :?:
Thank you
Comments
It'e pretty simple: use Database.LoadFromDisk() in the place of Database.Register for each database. This loads the schema from the snapshot file instead of reading the schema directly from a SQL Server database.