My requirement is to compare data of two same structured sql server tables and generate a report as :
Col Name No of Row Matches No of Non Matc
Could you please suggest the best way to achieve this with SQL-Query/Stored-Proc/SSMS.
My requirement is to compare data of two same structured sql server tables and generate a report as :
Col Name No of Row Matches No of Non Matc
Could you please suggest the best way to achieve this with SQL-Query/Stored-Proc/SSMS.
Please provide schema of these tables
Don't have specific schema but on general basis, need to perform the comparison.
below is a basic approach. You can also look into exclude statement
select sum(case when a.field1 = b.field1 then 1 else 0 end) as match,
sum(case when b.field1 is null then 1 else 0 end) as NoMatch
from tablea a
left join tableb b
on a.field1 = b.field1