Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem creating Foreign Keys...

Status
Not open for further replies.

Sheffield

Programmer
Jun 1, 2001
180
0
0
US
Greetings,

I'm relatively new to SQL Server 7 and am having difficulty creating Foreign Keys for existing tables that I wish to establish relationships between. (I think I inherited a mess.)

Can Foreign Keys be created in Enterprise Manager? Do 'Foreign Key Contraints' essentially create Foreign Keys?

I greatly appreciate anyone that can help clear this up:)

 
There are a couple of ways to create foreign keys in EM but here is one:

In EM you can go to tables. Right click on the table in question and go to design. Right click anywhere in the blank space and select the relationship item. This will open up a window for creating your relationships(Foreign key).


Hope this helps you out....
 
Jitter, thank-you for your response.

However, in bringing up the Properties dialog box, three tabs visible: Tables, Relationships, Indexes/Keys.

For reasons unknown, nothing on the 'Relationships' tabs is enabled for changing. Thus, nothing can be added to this tab.

Can you clue me in as to why this is the case OR let me know how else I can add an Foreign Key in Enterprise Manager?


Many thanks thus far...:)
 
When you are on the relationships tab go ahead and click New. This will open up the fields and let you create the foreign relationship.
 
There isn't a New button to click. (I have SQL Server 7.0. Perhaps this button exists on SQL Server 2000?

Thanks for your help thus far. I would greatly appreciate any more help you can give:)
 
Sorry Sheffield. It may be for 2000. I don't have a 7.0 EM box to play with so I can't tell you.

I guess I would check your Books Online. That should explain how to do it with both T-SQL and EM.

Wish I could have been more help.
 
Unfortunately the method Jitter describes does not exist in SQL 7.0.

One way is using the ALTER TABLE T-SQL command and adding a FOREIGN KEY constraint from there.

The other method is to create a database diagram add the required tables and then you can use drag and drop on the required columns.

Rick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top