Violation of PRIMARY KEY constraint 'PK_test'. Cannot insert duplicate key in object 'dbo.test'. The duplicate key value is (12610). (Source: MSSQLServer, Error number: 2627) ?

Hi team,
How resolve the below error 
Violation of PRIMARY KEY constraint 'PK_test'. Cannot insert duplicate key in object 'dbo.test'. The duplicate key value is (12610). (Source: MSSQLServer, Error number: 2627) ?
Thanks,
Ram
RAM

Hi team,
How resolve the below error 
Violation of PRIMARY KEY constraint 'PK_test'. Cannot insert duplicate key in object 'dbo.test'. The duplicate key value is (12610). (Source: MSSQLServer, Error number: 2627) ?
Thanks,
Ram
RAM
There can be two reasons
1. The insert script used is having multiple instances of the records with Key as 12610 returned from the source query. If this is the issue add a logic to include only the unique set of id values for records by avoiding duplicates. There are several approaches
for this like using ROW_NUMBER with PARTITION BY, using a join with derived table etc
2. The record with Key 12610 already exist in your destination table and your script is again trying to insert another instances of record with same key. This can be avoided by adding a NOT EXISTS condition with a subquery which will check and return only
those records which doesnt already exist in the source
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page

Similar Messages

  • SSIS - "Violation of PRIMARY KEY constraint. Cannot insert duplicate key in object ' tablename '. The duplicate key value is 1234 . Though there are no duplicate records.

    Hi,
    I am providing support to one of our clients, where we have jobs scheduled to load the data from the tables in the source database to the destination database via SSIS packages. The first time load is a full load where we truncate all the tables in the destination
    and load them from the source tables. But from the next day, we perform the incremental load from source to destination, i.e., only modified records fetched using changed tracking concept will be loaded to the destination. After full load, if we run the incremental
    load, the job is failing with the error on one of the packages "Violation of PRIMARY KEY constraint. Cannot insert duplicate key in object '<tablename>'. The duplicate key value is <1234>, even though there are no duplicate records. When we
    try debugging and running the failing package, it runs successfully. We are not able to figure out why the package fails and when we run the next day it runs successfully. Request you to help me in this regard.
    Thank you,
    Bala Murali Krishna Medipally.

    Hi,
    I am providing support to one of our clients, where we have jobs scheduled to load the data from the tables in the source database to the destination database via SSIS packages. The first time load is a full load where we truncate all the tables in the destination
    and load them from the source tables. But from the next day, we perform the incremental load from source to destination, i.e., only modified records fetched using changed tracking concept will be loaded to the destination. After full load, if we run the incremental
    load, the job is failing with the error on one of the packages "Violation of PRIMARY KEY constraint. Cannot insert duplicate key in object '<tablename>'. The duplicate key value is <1234>, even though there are no duplicate records. When we
    try debugging and running the failing package, it runs successfully. We are not able to figure out why the package fails and when we run the next day it runs successfully. Request you to help me in this regard.
    Thank you,
    Bala Murali Krishna Medipally.
    I suspect you are trying to insert modified records instead of updating.

  • Violation of PRIMARY KEY constraint . Cannot insert duplicate key in object

    hi i am using SQL Server, when i try to insert data from my jsp page it is inserting the data double time and when i try to submit for second time it is showing the following error.
    Violation of PRIMARY KEY constraint 'PK_EMPLOYEE'. Cannot insert duplicate key in object 'EMPLOYEE'.
    I didnt set identity for primary key. If i try to set identity to true then it is allowing data to submit only if i uncheck my primary key column in cached row set. And if i uncheck that primary key element then i can not retrieve the data by edit button. So how to solve this problem.
    Please any help would be appreciated.
    Thank You in Advance.

    Hi,
    I am providing support to one of our clients, where we have jobs scheduled to load the data from the tables in the source database to the destination database via SSIS packages. The first time load is a full load where we truncate all the tables in the destination
    and load them from the source tables. But from the next day, we perform the incremental load from source to destination, i.e., only modified records fetched using changed tracking concept will be loaded to the destination. After full load, if we run the incremental
    load, the job is failing with the error on one of the packages "Violation of PRIMARY KEY constraint. Cannot insert duplicate key in object '<tablename>'. The duplicate key value is <1234>, even though there are no duplicate records. When we
    try debugging and running the failing package, it runs successfully. We are not able to figure out why the package fails and when we run the next day it runs successfully. Request you to help me in this regard.
    Thank you,
    Bala Murali Krishna Medipally.
    I suspect you are trying to insert modified records instead of updating.

  • For some reason the function keys on my mac book changed, I restored them and now the shift keys have the function of showing the desktop and all windows.  I there a way I can restore the original function?

    For some reason the function keys on my mac book changed, I restored them and now the shift keys have the function of showing the desktop and all windows.
    I there a way I can restore the original function?

    You do not tell us what OS version you have. In OS 10.8.2, do this:
    Apple Menu / System Preferences / Language and Text / Input Sources.
    Select the language you want. Mine is set to Canadian English.

  • Primary Server went down going to get a fresh object elsewhere in the clust

    C:\>java -cp c:/oc4j_extended/j2ee/home/oc4j.jar;c:/how-to-ejb-clustering/lib/st
    ackClient.jar cluster.client.ClusterClient
    [One]
    [One, Two]
    [One, Two, Three]
    Kill current server and press Enter to continue.
    Primary Server went down going to get a fresh object elsewhere in the cluster
    Exception in thread "main" com.evermind.server.rmi.RMIConnectionException: Serve
    r shutdown
    at com.evermind.server.rmi.RemoteInvocationHandler.invoke(RemoteInvocati
    onHandler.java:50)
    at com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(Rec
    overableRemoteInvocationHandler.java:22)
    at com.evermind.server.ejb.StatefulSessionRemoteInvocationHandler.invoke
    (StatefulSessionRemoteInvocationHandler.java:40)
    at __Proxy2.push(Unknown Source)
    at cluster.client.ClusterClient.main(ClusterClient.java:45)

    Upss,i forgot to inform :
    i have my BC4J deployed ( +- 10 Entity objects/View objects ) , 1 Application Module
    i also developed java client to access this BC4J component,and calculate the average process time.
    Thanks
    Regards,
    Ricky HP

  • I keep getting the start menu and various programmes opening when I use a series of keys when working in my accounting programme, I am not using the command key and is very frustrating me, can anyone help me?

    I keep getting the start menu and various programmes opening when I use a series of keys when working in my accounting programme, I am not using the command key and is very frustrating, can anyone help me?  I am working on a Mac OS X Version 10.6.8, just need to know if I can reprogram the keys to stop this happening?

    Safari browser and menu shortcuts:
    http://docs.info.apple.com/article.html?artnum=42951
    Mac OS X keyboard shortcuts:
    http://support.apple.com/kb/HT1343
    http://docs.info.apple.com/article.html?artnum=75459
    Changing behavious of Function Keys:
    http://support.apple.com/kb/HT3399?viewlocale=en_US
    and more useful information on keyboard shortcuts here:
    http://www.myfirstmac.com/index.php/mac/articles/mastering-keyboard-shortcuts
    How to re-map individual keys:
    http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&item_id=ukelele

  • Insert data into table 1 but remove the duplicate data

    hello friends,
    i m trying to insert data into table tab0 using hints,
    query is like this..
    INSERT INTO /*+ APPEND PARALLEL(tab0) */ tab NOLOGGING
    (select /*+ parallel(tab1)*/
    colu1,col2
    from tab1 a
    where a.rowid =(select max (b.rowid) from tab2 b))
    but this query takes too much time around 5 hrs...
    bz data almost 40-50 lacs.
    i m using
    a.rowid =(select max (b.rowid) from tab2 b))....
    this is for remove the duplicate data..
    but it takes too much time..
    so please can u suggest me any ohter option to remove the duplicate data so it
    resolved the optimization problem.
    thanks in advance.

    In the code you posted, you're inserting two columns into the destination table. Are you saying that you are allowed to have duplicates in those two columns but you need to filter out duplicates based on additional columns that are not being inserted?
    If you've traced the session, please post your tkprof results.
    What does "table makes bulky" mean? You understand that the APPEND hint is forcing the insert to happen above the high water mark of the table, right? And you understand that this prevents the insert from reusing space that has been freed up because of deleted in the table? And that this can substantially increase the cost of full scans on the table. Did you benchmark the INSERT without the APPEND hint?
    Justin

  • Using function keys (F1, F2, ...) without needing to hold down the fn key

    By default on the Sprout, you need to hold down the "fn" key in order to access the real function keys (F1, F2, F3, ...) instead of the "actions" indicated by the icons on the keys. Normally, there's a BIOS option that lets you change this, so that the F1, F2, F3... function keys work without needing to hold down the "fn" key. E.g. as described in this article:
    http://h10025.www1.hp.com/ewfrf/wc/document?docnam​e=c02035108&cc=us&dlc=en&lc=en&jumpid=reg_R1002_US​...
    However, I don't see this BIOS option in the Sprout's BIOS, which looks quite different than the BIOS in that article.
    Is there some way to change the "fn" key behaviour?
        ...Tim...

    Hi Streup,
    Simple... On the S440 keyboard if you look at the top-left key.. Esc.. You should see a second label "FnLk" - Function Lock.
    Press the Fn key and then Esc.  The Fn Key will light up and now the Function Keys are activated.
    Repeat the same to get the smart keys back.
    Hope this helps
    Mark

  • Is there a fix for the noisy keys on a HP Pavilion dv7 6163 US? Especially around the "a" key

    Is there a fix for the noisy keys on a HP Pavilion dv7 6163 US? Especially around the "a" key

    I have the same problem, and this did NOT fix the issue!
    Edit:  I would give you negative kudos if I could.  I have seen hp reps post this as a solution way too many times.  THIS DEFINITIVELY DOES NOT FIX THE ISSUE!

  • While starting up portal server gateway I get an error "cannot read from rp.keystore, unable to read the PKCS key".

    The OS is solaris 8 and portal server 3. The first installation went through properly and we had installed many other applications also along with portal server. Then we had to ship the machine to some other city and restarted with same IP address, host address and domain, and also made a LAN without hooking onto the main network. From then on we are facing this problem. Even tried reinstallation a couple of times, after uninstall and deleting/renaming rp.keystore. The main problem looks like gateway not being able to read rp.keystore. The password required for reading it is the admin password which works fine the admin console.By invoking certstore also I am getting the same error.

    There is a couple of things I can think of here, one is the permission, you need to install the gateway as root , make sure the gateway and relevant files are installed as root and have the right access permissions.
    There should be file called .rppass and this contains the password and this should match the same password that you have used for the admin console.
    I would recommend you to use 3.0sp3a instead of 3.0 for better performance and scalability.
    HTH ..

  • Key-code change... from windows to mac... the old key-code doesn´t work

    I bought a CS for Windows and used it on Windows.
    Now I bought a Mac and want to use it,
    but the key-code doesn´t work.
    How can I get a key-code wich works???

    Neither the keycode nor the Windows version of the software will work on a Mac.
    You can only swap platforms for the latest version of Adobe products, which is currently CS6.
    Order product | Platform, language swap

  • I have the key; but it's not recognized. I can't enter the whole key into the 3 boxes provided

    ''locking as a duplicate - https://support.mozilla.com/en-US/questions/874827''
    The key I was provided is about 30 characters long, with 5 dashes.
    When I try to set up the sync, I am provided with 3 textboxes. When I enter the key, the characters' size is so large, I can only fit 3 characters per box. Therefore I can not enter whole key.
    I don't see option to change the size. So, what do I do?
    I have tried entering a number of different sequences of characters, starting with the first letter and then starting with the second, etc.
    Nothing seems to work. I keep getting an error.

    If you have a sync key instead of the passphrase then you need to click the link that I don't have the device with me and fill the name (email) and password and sync key fields.
    * Click "I already have a Firefox Sync account" : Connect
    * Click "I don't have the device with me" at the bottom
    * https://support.mozilla.com/kb/How+to+sync+Firefox+between+my+desktop+and+mobile
    * https://support.mozilla.com/kb/where-can-i-find-my-firefox-sync-key

  • I cannot get Lightroom to open, it gets to the first part then says, "Lightroom encountered and error when reading from its preview cache and needs to quit." Then "Lightroom will attempt to fix this problem the next time it launches". It doesn't fix anyth

    HELP!!!!!!!

    Using Explorer/Finder, locate your Lightroom catalog folder....inside that you will find a file called "yourcatalogname Previews.LRDATA", delete it (taking very great care that you do NOT delete the file ending in LRCAT) and restart Lightroom.

  • I cannot back up my iPad 1st Gen on the new version of iTunes, I get an error saying it is incompatible.  I need to back it up so I can then restore into my new iPad Air.

    How do I get around this?  The iPad one has the most current iOS allowed for the 1st gen per settings.
    Help!

    this is a follow up from the profane post earlier....
    i have done this twice in two other posts..
    here is my problem.. i started off trying to update itunes, it failed twice and said i needed to install manually via tools.
    the only place to get to tools is the pop up box that appears when you click check for updates.. if there is an available update then the pop up shows up with the quick time and itunes files to download. so i finally figured that out. i clicked on tools and manual update, four files were saved to a file. Apple mobile device support, another one similar, itunes, and another one i cant remember. I only downloaded the itunes file seeing as though thats all i needed to accomplish in the first place.
    so then i restarted my computer bc you need to reboot and then reopen itunes for update to take effect. once i have itunes back open i plugged in my new 5s which i am trying to sync to my computer to get all my stuff back bc i lost my previous phone over the weekend.. once i plugged the phone in an error stating i needed to unistall the apple mobile device support and itunes and then reinstall. well i dont know where those files were originally stored on my computer AND since my itunes was updated, just not the other 3 associated files, when i click check for updates it says its up to date and then pop up containing the quick time and itunes does not pop up thus i cant get back to the tools tab to manually save the 4 files again.
    so i was just going to uninstall itunes all together and then i thought well what happens if it erases all my photos apps songs etc... which would defeat the whole purpose in the first place of me trying to sync my new phone to get all my stuff back.
    so i literally have no idea what to do at this point.. if you have read this you are probably just as confused as me...

  • IDOC to MSsql,  error in mapping(Violation of PRIMARY KEY constraint)

    Hi All,
    I'm working with MATMAS IDOC  to MSSql. My SQL structure is of 8 tables(multiple statements) with primary key. In mapping i have used UPDATE_INSERT in action field for all the tables but still im getting "Violation of PRIMARY KEY constraint" for the last table structure. first 7 tables are single occurances but the 8th structure data is coming multple times from IDOC(E1MARMM).
    my 8th table structure is :
    STATEMENT8                                IDOC(MAPPED)
    TABLE8
    ACTION                                      UPDATE_INSERT
    TABLE                                           TABLENAME
    ACCESS     0 to Unbounded            MAPPED with E1MARMM
    Item_CD                                used oneasmany +splitbyvalue with MATNR
    Plant_ID                                  used oneasmany +splitbyvalue with WERKS  
    EAN_CAT                                 used oneasmany +splitbyvalue with NUMTP
    EAN                                             used oneasmany +splitbyvalue with EAN11
    Numerator_For_Conversion_To_BaseUOM
    Display_UOM
    Denominator_for_conversion_To_baseUOM
    KEY           0 to Unbounded                 MAPPED with E1MARMM
    Item_CD                                used oneasmany +splitbyvalue with MATNR
    Plant_ID                                  used oneasmany +splitbyvalue with WERKS  
    EAN_CAT                                 used oneasmany +splitbyvalue with NUMTP
    EAN                                             used oneasmany +splitbyvalue with EAN11
    Display_UOM
    in test tab its fine and fetching number of times according to MARMM segments  but in END to END testing its triggering an error stating that
    ""Message processing failed. Cause: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Error processing request in sax parser: Error when executing statement for table/stored proc. 'MM_EAN' (structure 'STATEMENT8'): com.microsoft.sqlserver.jdbc.SQLServerException: Violation of PRIMARY KEY constraint 'PK_MM_EAN'. Cannot insert duplicate key in object 'dbo.MM_EAN'.  ""
    Plz help me regarding this..

    Hi team,
    How resolve the below error 
    Violation of PRIMARY KEY constraint 'PK_test'. Cannot insert duplicate key in object 'dbo.test'. The duplicate key value is (12610). (Source: MSSQLServer, Error number: 2627) ?
    Thanks,
    Ram
    RAM
    There can be two reasons
    1. The insert script used is having multiple instances of the records with Key as 12610 returned from the source query. If this is the issue add a logic to include only the unique set of id values for records by avoiding duplicates. There are several approaches
    for this like using ROW_NUMBER with PARTITION BY, using a join with derived table etc
    2. The record with Key 12610 already exist in your destination table and your script is again trying to insert another instances of record with same key. This can be avoided by adding a NOT EXISTS condition with a subquery which will check and return only
    those records which doesnt already exist in the source
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

Maybe you are looking for