Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Posts
    8

    Question Unanswered: Duplicate key ignored !!!

    Hi guys,

    i have the following tables:

    Table1:
    [PKID] WITH INDEX "IGNORE DUPLICATE KEY"

    Table2:
    [FKID]


    and i have the following SQL statement:

    insert into Table1
    select distinct FKID
    from Table2
    where FKID not in (select PKID from Table1)



    The above SQL statement is in a DTS package which raises "Duplicate key ignored" error... i can't see how that can happen since i am already checking the key if it already exists. ..

    Please help !!!

    TNT :s

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Duplicates are probably in Table2.

    Not that this has ever happened to me, but I read about it in this book once.

    -PatP

  3. #3
    Join Date
    Mar 2004
    Posts
    8
    Thanks for replying pat.

    Duplicates are not selected from table2 since the 'distinct' keyword is used.

    Very wierd problem... i don't have much hair left to pull out :s

    T.

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Without having sample tables and data, it is tough (near impossible) to eliminate all of the possibilities. My guess is that you have non-duplicate values in table2 that become duplicates in table1 (this often happens due to type changes, etc).

    If you can post the table definitions and some sample data, I'm certain that one of us can figure out your problem... Without them, all we can do is guess... Your description of the problem probably won't help us much.

    -PatP

  5. #5
    Join Date
    Mar 2004
    Posts
    8
    Thanks for your response.
    i will post some data when the problem occurs again.

    Thanks again.
    TNT

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •