In SQLServer 2008 r2. I need to figure for a specific table what FK's in other tables point to it.
I try:
SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
But this does not give me what I need.
Any tips?
|
In SQLServer 2008 r2. I need to figure for a specific table what FK's in other tables point to it. I try:
But this does not give me what I need. Any tips? |
|||
|
|
|
You want to use the management views:
and
The latter one has column and object IDs for both sides of the constraint, so you can do a query like:
|
|||
|
|
|
This looks like it may get you what you need: http://www.sqlskills.com/BLOGS/PAUL/post/Programmatically-picking-apart-foreign-key-constraints.aspx |
|||
|
|
|
This link is to a database reverse engineering script that I wrote a few years ago. Amongst other things it has a query that reverse engineers foreign keys. You may be able to get what you want by adapting it. |
|||
|
|