Thursday, February 5, 2009

Add a New Column on an Existing Table as a Foreign Key

In this script example, I needed to add a foreign key column onto an existing table. The table did not contain data


ALTER TABLE [FirstTable]
ADD NewKey_ID uniqueidentifier not null,
CONSTRAINT fk_Campaign_ID FOREIGN KEY (NewKey_ID )
REFERENCES SecondTable (NewKey_ID )

No comments: