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

How to find Foreign key & primary key relationships in Tables?

Status
Not open for further replies.

tmpalaniselvam

Programmer
May 14, 2000
68
IN
Hi!
I want to get some answers from you.
1. How many primary keys, can be added into the single table?
2. How can I find the foreign key information?

Thanks,
Palani.
P.S. If you think below question is not belonging this group, pls tell me.
Can I added a new column in a query, that column will feed inputs through user defined functions.?
 
Palani,
One Primary key per table, but up to 32 indexes, and other indexes can be Unique. Look in help for the Relation Object, which you can loop through to find relationships existing on tables. For visually seeing this, look at the Relationships window (when the main database window is active, it's on the iconbar, it looks like 3 little datasheets connected). Here you can view the relationships.
--Jim
 
Palani:
Want to easily see any of that information, in a query that you can make reports on? Here's what I do in Access 97. Probably the same names and such for 2000, but I can't be certain just yet...

This SQL statement should give you a listing of all your relationships for a database:

Code:
SELECT
   R.szObject AS LocalTable;
   R.szColumn AS LocalKey,
   R.szReferencedObject AS ForeignTable,
   R.szReferencedColumn AS ForeignKey,
   R.szRelationship AS RelationshipName
FROM
   MSysRelationships AS R
ORDER BY
   R.szObject;

I hope you find that usefull.

-MoGryph
[8O)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top