how to set foreign key for sql table  using management studio

lucky20 used Ask the Experts™
Normally I use to set foreign key when creating a new table or using alter statement.

Now I want to set foreign key using design window in sql management studio.(in enterprise).

I guess it would be using menu in managemt studio.

did any one have idea about this.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Yes in managements studio:

Open up a server
Find your database
Find your table
Click on the drop down for the table do display Columns, Keys, etc
Right click on "Keys" and click "New Foreign Key"
Open SQL Enterprise Manager -> Select your Database -> Select Tables option -> right click and Create a New Table -> now right click on the newly created table -> Click Design option -> you will see a link in toolbar named Manage Relationships, click that -> In the Relationships tab -> Click New and define Primary Key Table/Fields and Foreign Key Table/Fields
Finally Apply all the settings by clicking OK button.

Add the two tables  to a database diagram and drag the FK column to the reference table



I am using sql server 2008..
I didn't find this  one
"a link in toolbar named Manage Relationships,"

when I right click on the row I can only see Relationships..
The Name is just «relationships».


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial