Thursday, 10 September 2009

Adding a foreign key - SQL Server

I confess to sometimes not using foreign keys when really I should be. Well now I have no excuse for forgetting how to implement them:

ALTER TABLE Orders 
ADD FOREIGN KEY (customerid) REFERENCES Customer;

No comments:

Post a comment

Comments are moderated, so you'll have to wait a little bit before they appear!