Merge\Combine two datatables

Posted by madlan on Stack Overflow See other posts from Stack Overflow or by madlan
Published on 2012-09-03T21:22:43Z Indexed on 2012/09/03 21:38 UTC
Read the original article Hit count: 621

Filed under:
|
|

I'm trying to merge\combine two datatables. I've looked at various examples and answers but they seem to create duplicate rows or require indexes (merge on datatable etc)

I can't do this via SQL as one source is from a linked Oracle server accessed via MSSQL and the other from a different MSSQL Server that does not have linked access.

The data is currently very simple:

Name, Email, Phone

DataTable1:

"John Clark", "", "01522 55231"
"Alex King", "[email protected]", "01522 55266"
"Marcus Jones", "[email protected]", "01522 55461"

DataTable2:

"John Clark", "[email protected]", "01522 55231"
"Alex King", "[email protected]", ""
"Marcus Jones", "[email protected]", "01522 55461"
"Warren bean", "[email protected]", "01522 522311"

Giving a datatable with the following:

"John Clark", "[email protected]", "01522 55231"
"Alex King", "[email protected]", "01522 55266"
"Marcus Jones", "[email protected]", "01522 55461"
"Warren bean", "[email protected]", "01522 522311"

Name is the field to match records on, with the first datatable taking priority.

© Stack Overflow or respective owner

Related posts about sql

Related posts about vb.net