Checking out dbForge’s Data Compare for SQL Server
Tags: devart, sqlserver, database
Published: 2022-05-27 13:08:56

If you are a professional SQL Server DBA, then at some point in your career, you’ve had (or will have) the need to perform the migration of data. Whether it is for an internal deployment within your environments or because you are seeking to modernize your database infrastructure (especially nowadays with so many cloud offerings). When such migrations take place, you want to be 100% sure that you didn’t leave anything behind (assuming that you want to lift and shift your data, of course), and [SQL Data Compare](https://www.devart.com/dbforge/sql/datacompare/) is a wonderful tool that can help you walk that path beautifully.

**Installation**
You can [download](https://www.devart.com/dbforge/sql/datacompare/download.html) dbForge Data Compare by clicking on one of the “Get Trial” buttons. However, I highly recommend clicking the one that says “dbForge SQL Tools Professional Trial” because that will also include the SSMS extension, which is totally worth it.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/au9cwnsjt21ugm1tsgoi.png) 

_**Note:** From this point forward, I will be using the stand-alone version of Data Compare._

Once you open Data Compare, this is what you will see:

Since we don’t have anything set up, because it’s the very first time that we’re opening Data Compare, then let’s click “New…”.
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2aif2e1xcly5psy1jozw.png) 

It will take us to this screen, where we should specify the source and target information to connect to the respective databases that we wish to compare.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x4gwc4ks0m8nv5e862qj.png) 

When you click the “Type” dropdown, it will give you the option to compare a database, a backup file, or a set of scripts. By the way, you are not limited to comparing the exact same type for source and target, and you can perfectly compare a database against a backup file.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4abrnxq259cux9n5b20t.png)  

Let’s go ahead and try the database option to see what output we get:

You’ll see a bunch of options to configure the comparison that will be carried out. Make sure to take the time to go through all of the available options so that you can customize it to your own particular case.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5607ei5gxcsgwc0dijzv.png)  

Following that, we get the option to specify the objects to compare:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t1ppcnet6c5kutefu6gi.png)  

This is what you get after you click on “Compare”:

By comparing the data using the primary key on each side, it will tell you the differences it encounters, something I can already find very useful for double-checking data migration scenarios instead of relying on either a tedious manual process or a time-consuming custom-developed routine.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n7s7m9d92gw9c5pklezt.png)  

Not only that, if you find differences between the source and the target, you can hit that green arrow to synchronize the data, even cooler!

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fzv595cnwlcx41v7ll4b.png) 

That alone would’ve made my day and would be enough, but let’s continue to explore the other options to see how it operates. To spice up things a bit, I will delete some records in my target table, generate a database backup, and see what Data Compare does.

As you can see, It gives me this error message because the product currently supports the comparison of backup files of SQL Server instances lower than 2014. Since I only have a 2017 and a 2019 Developer instance, then I’m not able to show you this particular option. However, digging up a bit, I stumbled upon a forum discussion (in [Devart forums](https://forums.devart.com/viewtopic.php?t=31428)) where it is mentioned that the product will eventually support comparing backups of higher SQL Server versions. Hopefully, this will come sooner rather than later, and I’m totally sure it will because I totally have faith in Devart because of what they’ve accomplished so far because in terms of products for SQL Server DBAs, it is nothing short of amazing!

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rjd9crf1p8t4hggsaytd.png) 

Moving up to the next option, I’m going to try comparing a generated database script against a database in one of my instances. For this, I have simply just used SQL Server Management Studio to generate a single script file of my source database and have placed it in the directory that will be entered in the options panel.

_*Additionally, make sure to select the correct collation so that you avoid any warnings up ahead. Or you can tick the “Use target database properties” checkbox if that’s good enough for you._

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f55uj41dns20omsvcrk8.png)  

Here we will see pretty much the same window showcased in the previous demonstration, so the same advice applies here: make sure to take your time to understand and enable/disable all the options that perfectly adhere to your own particular use case.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/041ct3nmronq11r5eif7.png)  

In the next screen, we will see the detected objects to be compared, so here you can choose whatever it is that you are targeting.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uwsww267i3qra0ecn804.png) 

This is the output I got, so it basically detected that in my script, there was a table also named “table1”, and compared using that.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6t8bsngc3zeph4dxyu0b.png) 

One very cool feature I forgot to bring up is that you can export the comparison data into HTML, CSV, or XLS format, which is highly convenient for you to have to share with your superior, a developer, or simply to document your work.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gvsz7ouapslu4pg3u3ji.png)
  
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g7lr3klnt05aupi2byeb.png) 

Whenever you are ready to proceed with the synchronization phase, then you’ll have the highly convenient option to perform a database backup prior to the synchronization. See, things like this are what make me have very high hopes in Devart when it comes to the development of new products/features and/or fixes in current products; this is because the attention to this particular detail is second to none; I salute you Devart team!

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yb1hbs5as37sylsylhap.png)  

After all, has been said and done, you’ll have a script of the actions applied at your disposal and the generated backup of the affected database in case things go south ;)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gewx73m5rswpzs99sku5.png)
  
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yt8j91oaae2av7q320t3.png)
 
**Final thoughts**
●	Synchronization of data can be a tough thing to keep an eye on if not done properly. However, dbForge Data Compare simply makes it easy and convenient for you.

●	I remember several years ago, working on a database migration project, I had to go through many hoops to compare the source against the target. I wish I had a tool like this to help me with my workflow; I can now appreciate the value it gives to the professional DBA, and you definitely have the opportunity to give it a shot.

●	This was a high-level approach to the tool. If you keep digging deeper, you will find more useful stuff, like automating operations from the command line, which basically allows you to integrate the tool with your DevOps daily operations.

●	You can find way more information in Devart’s [official documentation center](https://docs.devart.com/data-compare-for-sql-server/) for Data Compare.