Add a Primary Key Constraint to an Existing Table

Here are some handy snippets for how to create a primary key on an existing table. To add an identity column on the fly and then make it a primary key … To add a primary key to an existing column that is not null – first set the nullable column to NOT NULL … […]