Sorry for the lack of TIL lately, I just got off a two week bender of events – first Ladies Learning Code and second HackREGINA, which just finished on Saturday. Back to blogging! Today’s subject is the Data Compare tool in Visual Studio.
I ran into a situation where I wanted to compare two sets of rows in the same table – I was comparing the output of an old process to the new billing process I was working on at work. Unfortunately, I wasn’t able to find anything that did that (compare row data within the same table), but in the middle of my research I found out that Visual Studio (ultimate and premium) has its own data comparison tool!
Using the VS data comparison tool, which is installed when you install the SQL Server Data Tools, you can compare the rows between two tables in two different data sources. Once you have your data sources selected, you can specify which subset of tables and views you’d like to compare.
Once it’s done working its magic, you get a nice grid of rows that are different, rows that are the same, and rows that are missing in either data source. From there, you can view the individual rows, and even generate a changescript to make the data sources match each other!
This is just as useful as some other data comparison tools, like Red Gate’s SQL Compare, but with an added benefit of being integrated directly into your IDE. While it didn’t end up solving the problem I had at the time (I ended up writing code to manually loop through each row), I can definitely see myself using it in the future.