Creating a Table Relationship using SQL Server 2008 Management Studio

Most of the time we used to create table relationship using SQL Query Analyzer by writing the SQL Scripts, but today I thought why not to use Management Studio, guess what it took me more then 30 min to find out how, sounds silly!

Anyways if you too get stuck somewhere in this, I am giving you the steps how to do that.

I have created a Database called AddressBook, and added few tables named, Person, Address, Phone, etc. Now I want to create the relationship between Person and Address table, where PersonId from Person table will be the FK in Address table and Phone table.

1. First obviously open the SQL Server Management Studio

2. Right click the table you want to edit and select Design.

image

3. Now Select the Relationship by clicking anywhere in the table design or from the menu

image

4. Once the Foreign Key Relationship windows open, select Add button to add a new relationship and then select the ellipse button just next to the Tables and Column Specifications button in the right side of the pane.

image

5. This opens the Table and Columns windows where you can create a new relationship.

image

This is simple, I hope this help you !!!

2 Comments

Comments have been disabled for this content.