How to enable primary keys for the populated tables?

When I created the tables and the constraints, I forgot to do the following:

ALTER DATABASE warehouse SET EnableNewPrimaryKeysByDefault = 1;
ALTER DATABASE warehouse SET EnableNewUniqueKeysByDefault = 1;

Now I have populated the tables, how can I enforce the primary keys without staring over?


  • Options
    drlovedrlove Employee

    You can enable a constraint on an already populated table with ALTER TABLE. The constraint would be enforced for current content as well as content you add to the table later.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file