LOADING DATA INTO A CONSTAINED TABLE

  • The Gurus,

    I have the table with the structure and data below.

    user_id option_id setting enforced

    0 1000 -1 N

    0 1001 -1 N

    0 1002 -1 N

    0 1003 -1 N

    1 1006 0 N

    1 1007 0 N

    1 1008 -1 N

    There is a primary key constraint called PX_OPTION on the table. I want to change all the ones in the user_id column to zeros but I keep getting the error message below:

    Msg 2627, Level 14, State 1, Line 1

    Violation of PRIMARY KEY constraint 'PX_OPTION'. Cannot insert duplicate key in object 'dbo.CT_OPTION'.

    The statement has been terminated.

    Is there a way to do this without remove the primary key constraint?

    Thanks.

    Regards.

  • If you business logic dictates that this combination of columns allows for duplicates, then it is by definition not a primary key, it may be worth examining your table to determine whethere there is a column which can be included in a Candidate Key to give you a true primary key...otherwise you *don't* have a primary key....

  • Yes, agreed. If you're needing to do something that violates your primary key, either don't do it, or revise you primary key.

  • Thanks guys.

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

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