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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:31:50+00:00 2026-06-04T16:31:50+00:00

Is there a way to bulk upsert in SQL Server 2005? Something akin to

  • 0

Is there a way to bulk upsert in SQL Server 2005? Something akin to 2008’s MERGE would be perfect. I have one table working as a temp workspace that will need to be reconciled to the main table on session complete. In 2008, merge would do great for this, but the only 2005 methods I’ve seen are for individual upserts, not bulk. Ideas?

  • 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-04T16:31:51+00:00Added an answer on June 4, 2026 at 4:31 pm

    First do an update and then do the insert. Something like this.

    update TargetTable
    set Col1 = SourceTable.Col1,
        Col2 = SourceTable.Col2
    from SourceTable
    where TargetTable.ID = SourceTable.ID
    
    insert into TargetTable(Col1, Col2)
    select Col1, Col2
    from SourceTable
    where SourceTable.ID not in (select ID from TargetTable)
    

    Update:

    If you have more than one column in the primary key you can use not exists instead.

    update TargetTable
    set Col1 = SourceTable.Col1,
        Col2 = SourceTable.Col2
    from SourceTable
    where TargetTable.ID1 = SourceTable.ID1 and
          TargetTable.ID2 = SourceTable.ID2
    
    insert into TargetTable(Col1, Col2)
    select Col1, Col2
    from SourceTable
    where not exists (select * 
                      from TargetTable
                      where TargetTable.ID1 = SourceTable.ID1 and
                      TargetTable.ID2 = SourceTable.ID2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to do a bulk insert in Sql Server where rows
Is there any way to speed up bulk inserting in 2005? I'm looking into
We have used the excellent RSBuild for bulk uploading reports to SQL Server Reporting
A colleague tells me that there is no way to bulk insert UTF-8 encoded
Is there way that I can read the file from remote server using fopen
Is there a way to do something similar to a SourceSafe label in svn?
Is there any way to bulk-export Microsoft Access code to files? I see I
Via the Lighthouse user interface, is there any way to bulk stop watching tickets?
Is there a way to bulk evaluate the contents of an array in C++?
is there any way to insert in bulk (i mean all gridview rows) to

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.