Phman Super
asked on
Data Comparison and Update
Can anyone tell me how to compare 2 data tables and update the field if they are not match.
Example.
Table 1
Loan# TaxReturn BankStatement
123456 Y null
234567 N N
Table 2
Loan# TaxReturn BankStatement
123456 Y Y
234567 Y Y
if the Table1.TaxReturn not equal Table2.TaxReturn then use the Table2 value to update the Table1.
if the Table1.BankStatement not equal Table2.BankStatement then use the Table2 value to update the Table1.
it is ok to use Linq if the speed is faster.
Thanks
Example.
Table 1
Loan# TaxReturn BankStatement
123456 Y null
234567 N N
Table 2
Loan# TaxReturn BankStatement
123456 Y Y
234567 Y Y
if the Table1.TaxReturn not equal Table2.TaxReturn then use the Table2 value to update the Table1.
if the Table1.BankStatement not equal Table2.BankStatement then use the Table2 value to update the Table1.
it is ok to use Linq if the speed is faster.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Linq:
from t1 in table1
join t2 in table2 on t2.loan equals t1.loan
where t1.taskreturn<>t2.taskreturn
|| t1.bankstatement<>t2.bankstatement
select new
{ t1.loan,
t1.taskreturn<>t2.taskreturn?t2.taskreturn : t1.taskreturn,
t1.bankstatement<>t2.bankstatement?t2.bankstatement : t1.bankstatement
},
Open in new window