Simple yet effective Data Validation method !
Introduction In this post we will see how we can do data validation using CASE statement. Scenario We want to validate not only pick the records with data mismatch but also the exact columns where the data mismatch is present. We are aware that we can make use of EXCEPT queries to find the records with data mismatch, but in case there are millions of records in a our tables with large number of columns and if our except query fetches even few thousand records, it is simply a nightmare to zero in on the exact values. We can use JOIN coupled with CASE statement to do above. In the above scenario we have a case where we have a PK present, which we will use to JOIN and then do a column by column comparison using CASE statement to pick the data mismatches. P.S. Joining column must be present to make use of this query. USE tempdb GO SET NOCOUNT ON GO -- This table is one which is having correct data CREATE TABLE Table...