How do i compare two datatable values by matching in order to categorize a business rule exception between the two?
Since a data table contains of rows and each row can have one or more cells, a naive approach would be to loop over each row, and then compare cell by cell. If the values of a single cell aren’t equal, you would throw a Business Exception.
Another option I can think of is hash-based - just compare the hash values of each row as described here. If the hash is the same, compare cell by cell to make sure you didn’t just see two hashes collide.
You can use the datatable joins here.
For the join, use a Full join type so that it will insert Null for rows that do not match in both tables. Once you are done with the Full Join, use a Filter Data Table activity to get all the records that has nulls and that will be the set which you want to send a business exception to
If You want to check both datatables are same then you can use below query.
The datatable dtc will contains exactly matched rows of both the datatable dta and dtb. If you want to check both the datatables are exactly same then you can check the rows count of dtc with dta and dtb.