Adding column with primary key in existing table

后端 未结 5 1926
感动是毒
感动是毒 2021-02-02 12:29

I am trying to add primary key to newly added column in existing table name Product_Details.

New Column added: Product_Detail_ID (int

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-02 13:08

    You are getting the error because you have existing data that does not fullfill the constraint.

    There are 2 ways to fix it:

    • clean up the existing data before adding the constraint
    • add the constraint with the "WITH NOCHECK" option, this will stop sql server checking existing data, only new data will be checked

提交回复
热议问题