LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 2005, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 22 Nov 2005 17:03:50 -0500
Reply-To:   Peter Crawford <peter.crawford@BLUEYONDER.CO.UK>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Peter Crawford <peter.crawford@BLUEYONDER.CO.UK>
Subject:   Re: Getting a list of foreign keys
Comments:   To: Lorne Klassen <lk1@ROGERS.COM>

On Tue, 22 Nov 2005 13:19:13 -0500, Lorne Klassen <lk1@ROGERS.COM> wrote:

>I have a table that has a primary key. There are a number of foreign keys >in other tables (sometimes >1 column in a given table) that reference this >primary key. I need to write code that involves the primary key and all of >these foreign keys in other tables. I could hardcode all of this code. >However, I do not want to hard code it considering how many tables and >columns are involved. I would like a systematic way of finding out what >columns from what tables reference this primary key. I searched the SASHELP >views, thinking that SAS would have this information there but it doesn't. >Any ideas? Thanks in advance for replies.

sashelp.vrefcon provides info on referential integrity constraints.

sashelp.vindex is also worth a look It identifies indexes in any indexed tables in any assigned libraries.

Tables without referential integrity constraints may still be of interest where columns with consistent data names and types join to indexes in other tables. Of course, you may have undocumented referential integrity which uses different names in the primary and "foreign" keys. I see no way to automate identification of these cases.

Good Luck

Peter


Back to: Top of message | Previous page | Main SAS-L page