Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 Identifying source of foriegn key

Author  Topic 

vowell1055
Starting Member

1 Post

Posted - 2009-08-14 : 16:43:27
This seems like an utterly simple thing, but, for the life of me, I can't seem to find how to do it. How do you find out what table of which another table's foreign key field is the primary key? Does that make sense?

If table A has a field which is designated a foreign key field, how do I find out the table for which that is the primary key?

Again, probably very simple stuff, and I've tried searching for it, but none of the word combinations I've use has produced anything.

Thanks in advance!

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-08-14 : 16:56:58
Well you can right-click it in the Object Explorer and choose "Script to New Window as CREATE"

or, you can execute this:

select object_name(referenced_object_id) referencedTable
from sys.foreign_keys
where parent_object_id = object_id('YourTableNameHere')

Go to Top of Page
   

- Advertisement -