Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6151359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:45:32+00:00 2026-05-23T19:45:32+00:00

I have two data tables which have a primary key column in common but

  • 0

I have two data tables which have a primary key column in common but otherwise different structures as they’re created from different tables. I’d like to check which rows are missing from data table B compared to A, with the aim of adding in the missing rows to the database.

I’ve had a look at questions like this one, which provide good answers but the data tables are usually assumed to be the same.

Since I want to get a list of new rows for inserting, is there any way I can do this without iterating through the rows and checking the PKs? If I’m not mistaken, Merge will keep the old rows, which I don’t want to resubmit to the database.

Both tables will have only a few dozen rows, a couple of hundred maximum. Would the computational hit of doing it row-by-row be negligible anyway?

edit: the two source tables are on different databases/servers, so I can’t easily do the
comparison in SQL. I’d prefer the consuming application to do it anyway, as I may add some more row processing before I’m done.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:45:32+00:00Added an answer on May 23, 2026 at 7:45 pm

    I hope I’ve understood your needs correctly, but how about using Linq? Load the keys of your 2 tables into 2 IEnumerable<keytype> objects, e.g. (assuming your keys are of type int)

    IEnumerable<int> keys1, keys2;
    // code to load the keys into these collections
    // to find the keys in keys1 that are missing from keys2:
    var missingKeys = keys1.Where(k1 => !keys2.Any(k2 => k2 == k1)); 
    

    HTH

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables 'Elements' and 'Lists' Lists has a primary key and a
I have two mysql tables which both have a typeID in common. I am
I have two tables: <class name=Content table=language_content lazy=false> <composite-id> <key-property name=contentID column=contentID/> <key-property name=languageID
Imagine I have a table with two columns, a primary key and some data.
I have a two-dimensional array (of Strings) which make up my data table (of
I have two arrays of System.Data.DataRow objects which I want to compare. The rows
I have two projects, the DLL project which has all my logic and data
We have two tables, ActivityForm and Field which are given a many-to-many relationship via
I have two already-existing tables which look (in part) roughly like this: CREATE TABLE
i have two data tables with the same structure the first one has one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.