September 29, 2004 at 6:05 am
how could i know or collect foreign key in my database
September 29, 2004 at 6:54 am
Look up sp_fkeys in BOL (Books Online)
This will produce sql to find foreign keys in current database
SELECT 'exec sp_fkeys '+name FROM sysobjects WHERE type = 'u'
copy and paste results into another QA windows and execute
Far away is close at hand in the images of elsewhere.
Anon.
September 29, 2004 at 8:49 am
There are also system table views provided by Microsoft that can provide foreign key information. They are:
information_schema.constraint_table_usage
information_schema.constraint_column_usage
information_schema.table_constraints
You query them as you would any other table or view except you must qualify them and you can access them from any database:
select * from information_schema.constraint_table_usage
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply