Having Fun with VS2010 Ultimate: SQL Data Comparison

Original author: Zubair.NET!
  • Transfer
When playing with Visual Studio 2010, I discovered that the Ultimate (and Premium) editions come with a utility for comparing data and SQL schemas, and decided to check.

I made two databases, SourceDB and TargetDB with a single Customer table. Here's what the data looks like in the tables.



Master


Next, I selected Compare Data for the source table in Server Explorer.

In the dialog that appears, I selected the destination database and clicked Next - I decided to leave all the options checked.

The following dialog showed tables and views that I would like to compare - in my case, only Customer.


Result


Now for the fun part,

Changed entries are highlighted, of course.
In addition to the records that need to be updated, note that there is one record in the source table that must be added to the final table and one completely identical that must remain unchanged. Let's look at them.



Update


But we have not finished yet. Of course, I can update the final database directly from VS, for this I have two ways - to generate a script or let VS2010 update the data for me. Because Anyway, I just play with opportunities, I think it's worth looking at both options. To begin with, we select

This will give us the generated Sql script, which can be used to update the course database. It looks something like this:

If you look deeper ... mm ... VS disables FK constraints, performs all operations - and turns it back on, fine.
Because I'm a little lazy, I want Visual Studio to do all the work for me - and all that needs to be done ... right-click and select ...

VS2010 will show a confirmation dialog, I know what I'm doing, so just click OK and the changes will be published in the final database .

Also popular now: