LOADING DATA INTO A CONSTAINED TABLE

  • The Gurus,

    I have the table with the structure and data below.

    user_idoption_idsettingenforced

    01000-1N

    01001-1N

    01002-1N

    01003-1N

    110060N

    110070N

    11008-1N

    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