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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:26:18+00:00 2026-05-26T09:26:18+00:00

Ive been experimenting with inserting data and updating if there is a dup. Here

  • 0

Ive been experimenting with inserting data and updating if there is a dup. Here is my code. All of these fields are keys. Each is unique and if there is a dup, all three fields are consistent. Only one NUMBE for one TYPE for one TrackingNumber and so on.

    string statement = 
   "INSERT INTO SOP10107 VALUES(@SOPNUMBE, @SOPTYPE, @Tracking_Number) 
    ON DUPLICATE KEY 
        UPDATE(@SOPNUMBE = SOPNUMBE + 1, 
               @SOTYPE = SOTYPE + 1, 
               @Tracking_Number = Tracking_Number + 1 )";

Since I am new, Im not sure if this is correct (or anywhere near correct), I think the basic format is right, but the specific grammer and wording I am having some trouble on. The error will come back and say that there is a problem with “ON”. It is most likely a format error. Anyone care to help me out or shed some light on the matter? Thank you so much in advance!

  • 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-26T09:26:18+00:00Added an answer on May 26, 2026 at 9:26 am

    You can use the new MERGE statement in SQL 2008

    MERGE INTO SOP10107 B
    USING (
      SELECT sopnumbe,sotype,tracking_Number  FROM SOP10107 ) E
    ON (B.tracking_number = E.tracking_number)
    WHEN MATCHED THEN
      UPDATE SET B.SOPnumbe  = B.Sopnumber +1,
             B.sotype = B.Sotype +1,
             B.tracking_number = B.tracking_number +1
    WHEN NOT MATCHED THEN
      INSERT (sopnumbe,sotype,tracking_Number )
      VALUES (@SOPNUMBE, @SOPTYPE, @Tracking_Number);
    

    MERGE Command in SQL

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

Sidebar

Related Questions

I've been experimenting with some code code on Ayende Rahien's blog here which demonstrates
I've been experimenting with using MS Excel 2007 to edit tabular data stored in
After being stumped by an earlier quesiton: SO google-analytics-domain-data-without-filtering I've been experimenting with a
I've been experimenting with Hive for some data mining activities and would like to
I've been experimenting with various bits of Java code trying to come up with
I've been experimenting with both ggplot2 and lattice to graph panels of data. I'm
Now that C++0x is almost here, I've been experimenting with it, and in particular
I've been experimenting with xhtml and now I'm wondering that is there a valid/correct
I've been experimenting with using mvc-mini-profiler on a ASP.NET website. All of the request
I've been experimenting with ScraperWiki and yesterday, I could get a list of all

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.