|
Home > Archive > Microsoft SQL Server forum > January 2006 > how to get tables involved in constraint
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
how to get tables involved in constraint
|
|
|
| Hi,
The following request select a constraint from TABLE_CONSTRAINT with
the name specified in the where clause:
select * from INFORMATION_SCHEMA.TABLE_CONSTRAINTS where
constraint_name = 'FK__51OtherParties_
_51Claims'
It returns:
http://graphicsxp.free.fr/constraint.JPG
So I have TABLE_NAME that correspond to the first table involved in the
constraint, but how do I get 51Claims ????
Thank you
| |
| Razvan Socol 2006-01-18, 11:24 am |
| Hi, Sam
You can use something like this:
SELECT TC.TABLE_NAME
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS TC
INNER JOIN INFORMATION_SCHEMA. REFERENTIAL_CONSTRAI
NTS RC
ON TC.CONSTRAINT_NAME=RC. UNIQUE_CONSTRAINT_NA
ME
AND TC. CONSTRAINT_SCHEMA=RC
. UNIQUE_CONSTRAINT_SC
HEMA
WHERE RC.CONSTRAINT_NAME = 'FK__51OtherParties_
_51Claims'
Razvan
| |
|
| Hi Razvan,
Many thanks, it works !
|
|
|
|
|