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

  • Home
  • SEARCH
  • 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 472423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:05:08+00:00 2026-05-13T00:05:08+00:00

DB gurus, I am hoping someone can set set me on the right direction.

  • 0

DB gurus,

I am hoping someone can set set me on the right direction.

I have two tables. Table A and Table B. When the system comes up, all entries from Table A are massaged and copied over to Table B (according to Table B’s schema). Table A can have tens of thousands of rows.

While the system is up, Table B is kept in sync with Table A via DB change notifications.

If the system is rebooted, or my service restarted, I want to re-initialize Table B. However, I want to do this with the least possible DB updates. Specifically, I want to:

  • add any rows that are in Table A, but not in Table B, and
  • delete any rows that are not in Table A, but are in Table B
  • any rows that are common to Table A and Table B should be left untouched

Now, I am not a “DB guy”, so I am wondering what is conventional way of doing this.

  • 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-13T00:05:08+00:00Added an answer on May 13, 2026 at 12:05 am

    Use exists to keep processing to a minimum.

    Something along these lines, modified so the joins are correct (also verify that I didn’t do something stupid and get TableA and TableB backwards from your description):

    insert into TableB
        select 
            *
        from
            TableA a
        where
            not exists (select 1 from TableB b where b.ID = a.ID)
    
    delete from 
        TableB b
    where
        not exists (select 1 from TableA a where a.ID = b.ID)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am at a dead end, so hoping you jQuery gurus can help. I
Hope the AWK gurus can provide a solution to my problem . I have
Calling all MQ Gurus, I have a box under my desk which we use
Hi all NHibernate gurus ! Given these two classes : public class User {
Objective C gurus, I have a quick question to ask: I now have two
I have a brain-teaser for all you SQL Server 2008 Reporting gurus out there
I'm hoping someone out there can tell me what's causing the Continue button to
Gurus! Can anybody answer: where defined parameter numPartitions in Partitioner class(value of this paramen)?
gurus. I have a perl script which needs to run in an infinite loop
LINQ gurus, I am looking for help to write a query... I have a

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.