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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Foreign Key 1

Status
Not open for further replies.

Coy

MIS
Jun 18, 1999
3
US
Hello everyone:<br>
<br>
I am brand new to SQL Server (1 day and running!). I am trying to set foreign keys for various tables, and want to make sure I am doing it correctly. I had no problem setting the primary key in the enterprise manager, but was a little confused setting the foreign key for my child table. <br>
<br>
I created my child table and selected the advanced button. Then, I went to the "referenced table" combo and selected my parent table for the reference. Then, I selected the field I want to name for a foreign key in the "foreign key columns" box. Once I did that, I selected ADD. Once I did that, the top box, labeled "foreign key" was filled in with FK__ 3 ___ 10.<br>
<br>
Nothing special happened after I did this, so I presume I did this correctly. However, when I closed the table and re-opened it again, the values I selected in the foreign key tab to create my foreign key were no longer there!<br>
<br>
Did I do this correctly? I am probably making a bigger deal out of this than I should.... it is just very different from FoxPro, which I am use to working with.<br>
<br>
Thanks in advance for any comments
 
Hi Coy,<br>
<br>
To see if you successfully created your foreign key. Type this into an iSQL window:<br>
<br>
select * from sysobjects where type='F'<br>
<br>
Type = 'F' is a foreign key flag.<br>
<br>
You should see your key name.<br>
<br>
Or alternately, try to break your foreign key relation!!!
 
thanks for your reply calahans<br>
<br>
I ended up creating a ODBC connection to my SQL server database and working with the database in Interdev. Using the Visual Data Tools is fairly easy, and I was able to create database diagrams once I got there. I simply drag and dropped fields to create the relations, and indexed the appropriate keys.<br>
<br>
Thanks for your code. I will remember that for future reference.<br>
<br>
Coy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top