SQL Query to get the table names which use a particular column as a foriegn key
Posted
by
vinayvasyani
on Stack Overflow
See other posts from Stack Overflow
or by vinayvasyani
Published on 2011-01-07T22:25:37Z
Indexed on
2011/01/07
22:53 UTC
Read the original article
Hit count: 243
What sql query would you write to get the table names which have a particular foriegn key.
Eg. Person_Table(person_id,name,address,...)
Purchases_Table(purchaseid, purchased_by_id(fkey)....)
AccountDetails_Table(AccountId,PersonID,....)
Roles_Table(PersonId,RoleID)
Now i want to find the table names where Person id is used as a foreign key. The above schema would return me
Purchases_Table,AccountDetails_Table, Roles_Table
Database: SQL Server
© Stack Overflow or respective owner