Given a table A, I need to find all the tables that are in PK-FK with A and the columns in the reference. I can get the tables that have the FK relation through sysreferences or sysconstraints or sysforeignkeys but I have not been able to find out how to identify the specific column that is in the relation. Any one has any idea?
Sample:
SELECT * FROM sysreferences WHERE fkeyid = Object_Id('TableA')
Thanks.
Have you tried a system procedure sp_helpconstraint? You can get more detailed information about constraints including PK/FK of specified table. For example:
sp_helpconstraint 'TableA'
|||Thanks for the reply Iori_Jay. I managed to get something working.
No comments:
Post a Comment