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 8008311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:05:53+00:00 2026-06-04T18:05:53+00:00

I have a small problem with inserting information from one table to other. For

  • 0

I have a small problem with inserting information from one table to other.

For example: from table A (can contain ~10 kk entries) to table B, tables are identical except table A has DateTimeStamp which is used to take certain data (boundaries).

So I need to move data from A to B (without DateTimeStamp) and remove duplicates from B.

Example:

Table A

DateTimeStamp | Key | value 
2012-02-03    |  2  | 123
2012-02-03    |  3  | 985
2012-02-03    |  5  | 1584

Table B

Key  | value 
  8  | 45
  3  | 785
  9  | 7457

So I need to delete row with Key = 3 from Table B and insert everything else from Table A.

Results would be:

Key  | value 
  8  | 45
  3  | 985
  9  | 7457
  2  | 123
  5  | 1584

Is there elegant way to do this ? Triggers are too slow, and I am looking for solution that wouldn’t require temporary table.

SQL Server or SSIS solutions\suggestions are welcome

  • 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-06-04T18:05:55+00:00Added an answer on June 4, 2026 at 6:05 pm

    If you’re using SQL Server 2008 or newer, you could do this very easily with a single MERGE statement – something like this:

    MERGE INTO dbo.B                -- target table
    USING A ON b.Key = a.Key        -- source table and "link" information
    WHEN MATCHED 
        THEN UPDATE SET B.Value = A.Value   -- if "Key" already present in B - update "Value"
    WHEN NOT MATCHED                        -- if "Key" not present in B - insert new row
        THEN INSERT(TblKey, TblValue) VALUES(A.TblKey, A.TblValue) 
    WHEN NOT MATCHED BY SOURCE
        DELETE                              -- if present in B, but not in A -> remove
    ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have small problem with inserting data into my table events +-------+----------+------+-----+---------+----------------+ | Field
I have a small problem. I am creating an appointment table where in the
I have small problem with mysql. I have data in table and I want
i have small problem i.e. their is one celltable with lot of data it
I have small problem with JavaMail. Sometimes method getRecipients from class Message returns weird
have small problem, and would very much appreciate help :) I should convert byte
I have a small problem with Smarty... I have two different template files in
I have a small problem where I want to find the next active item
i have a small problem, i am creating a edit page in my asp.net
I have a small problem with a SWT.Browser widget who throws a quite puzzling

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.