Thursday, February 5, 2009

Set an Existing Column as the Primary Key

The column that becomes a primary key must be a uniqueidentity column and must not allow nulls.

Here's the script:

ALTER TABLE [MyTable]
ADD CONSTRAINT pk_MyTable PRIMARY KEY (MyColumn_ID)

No comments: