Hi,
I want to know which table my foreign is reference to
for instance I have this statement
ALTER TABLE BANK ADD CONSTRAINT BANKING_R_154 FOREIGN KEY (
COM_CODE ,
ACCOUNT_CODE ) references BANK_GLT
I want execute ine select * from information_schema.I_don't_know
to get the table BANK_GLT from constraint BANKING_R_154
How can I do this?
cheers,
Alessandro
Select * from INFORMATION_SCHEMA.Referential_Constraints RC
INNER JOIN INFORMATION_SCHEMA.Constraint_Column_usage CCU
ON RC.Constraint_Catalog = CCU.Constraint_Catalog AND
RC.Constraint_Schema = CCU.Constraint_Schema AND
RC.Constraint_Name = CCU.Constraint_Name
Where Table_Name = 'SomeTable' --for a table, use Constraint_Name for querying on Constraint Names
--
HTH, Jens K. Suessmeyer.
http://www.sqlserver2005.de
Thanks,
but, I would like to know which table my tables is reference to and which columns as well
cheers,
No comments:
Post a Comment