locked
UNIQUE KEY RRS feed

  • Question

  • User2033323258 posted

    dears

    I get this error when you use the UNIQUE KEY.

    Violation of UNIQUE KEY constraint 'IX_New'. Cannot insert duplicate key in object 'dbo.New'. The duplicate key value is (20). The statement has been terminated.

    What is the code to solve this issue.

    Saturday, May 25, 2013 11:03 AM

Answers

  • User-1469158370 posted

    This means that you are inserting a record with a duplicate value for the unique column. have a check in your code before inserting.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 25, 2013 11:27 AM
  • User-1716253493 posted
    check first the record using SELECT COUNT(*) FROM YOURTABLE WHERE IDFIELD=…
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 25, 2013 12:08 PM

All replies

  • User-1469158370 posted

    This means that you are inserting a record with a duplicate value for the unique column. have a check in your code before inserting.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 25, 2013 11:27 AM
  • User2033323258 posted

    I've put not to repeat " UNIQUE KEY ", but I see this error when I enter two identical .

    How can I put Labelerror no one Cannot insert duplicate number to Database

    Saturday, May 25, 2013 11:41 AM
  • User-1716253493 posted
    check first the record using SELECT COUNT(*) FROM YOURTABLE WHERE IDFIELD=…
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, May 25, 2013 12:08 PM
  • User2033323258 posted

    thanks for all

    Tuesday, May 28, 2013 6:23 AM