all groups > sql server (alternate) > january 2006 >
You're in the

sql server (alternate)

group:

how to get tables involved in constraint



how to get tables involved in constraint Sam
1/18/2006 8:15:18 AM
sql server (alternate): 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
Re: how to get tables involved in constraint Razvan Socol
1/18/2006 9:07:43 AM
Hi, Sam

You can use something like this:

SELECT TC.TABLE_NAME
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS TC
INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS RC
ON TC.CONSTRAINT_NAME=RC.UNIQUE_CONSTRAINT_NAME
AND TC.CONSTRAINT_SCHEMA=RC.UNIQUE_CONSTRAINT_SCHEMA
WHERE RC.CONSTRAINT_NAME = 'FK__51OtherParties__51Claims'

Razvan
Re: how to get tables involved in constraint Sam
1/18/2006 9:23:35 AM
Hi Razvan,

Many thanks, it works !
AddThis Social Bookmark Button