INSERT

  • I am trying to insert 3500 rows from table budget04 to budget05. I have an IDENTITY field in budget05 where there is no chance of inserting duplicate key but still I get this error message

    Server: Msg 2627, Level 14, State 2, Line 1

    Violation of UNIQUE KEY constraint 'IX_budget05. Cannot insert duplicate key in object budget05.

    The statement has been terminated.

  • What is your unique constraint 'IX_budget05' ?

  • I have 3 columns appno,appseq,ledger for that constraint

  • I assume appseq is the identity field?

    Is IDENTITY_INSERT set on/off for the particular table? (see SET IDENTITY_INSERT in the books online)

    What is your insert command?

  • So, you need to have

    GROUP BY appno,appseq,ledger

    in your INSERT statement as well as

    WHERE NOT EXIST (select 1 from IX_budget05 I

             where <value for appno> = I.appno and <value for appseq> = I.appseq and <value for ledger> = I.ledger)

    _____________
    Code for TallyGenerator

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply