0

For data assurance, my task is two compare two datasets from different databases. Currently I am performing the cell-by-cell value comparison which is a Brute Force method and is consuming lot of time.

I would like to know if there are any methods which would save my time and memory space, which is able to provide a result indication "Tables are identical" or "Tables are not identical".

Thank you for your assistance.

2 Answers 2

1

How about creating a checksum for each table and compare the them?

Something like:

SELECT CHECKSUM_AGG(CHECKSUM(*)) FROM TableX

This might need a ORDER BY to be more precise.

Sign up to request clarification or add additional context in comments.

9 Comments

My impression is that he needs to compare DataSets, not SQL Server tables, as evident from the tags.
Yeah, that could be true. But if the task is to compare the content of two tables (as far as I understand it), why load the whole data from the servers if you can just load two checksums and compare them in code?
Correct. Let's see if he provides more explanation.
One problem with this approch is that it might return false equalities. Two equals checksums doesn't ensure tables are equals in content. On the other hand it doesn't return false inequalities.
@JesúsLópez How do you mean that they are not equal in content?
|
1

If they are from different sources, there is no other way than comparing them cell by cell AFAIK. However I can suggest you something that will probably increasing comparison speed by many folds. If your DataTables have identical structures, which they hopefully should since you're already comparing them cell by cell, try comparing ItemArray of each pair of rows instead of accessing them by column index or column names (or row properties if you're using strongly-typed DataSets). This will hopefully give you much better results.

If you're using .NET 3.5 or above, this line should do it:

Enumerable.SequenceEqual(row1.ItemArray, row2.ItemArray);

1 Comment

Thanks for the thought . I will give it a try and check the difference in performance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.