Created
August 28, 2012 16:18
-
-
Save jacobsimeon/3499797 to your computer and use it in GitHub Desktop.
List tables with foreign key that references a given table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select t.name as TableWithForeignKey, fk.constraint_column_id as FK_PartNo , c.name as ForeignKeyColumn | |
from sys.foreign_key_columns as fk | |
inner join sys.tables as t on fk.parent_object_id = t.object_id | |
inner join sys.columns as c on fk.parent_object_id = c.object_id and fk.parent_column_id = c.column_id | |
where fk.referenced_object_id = (select object_id from sys.tables where name = 'PriorAuthorizationRequests') | |
order by TableWithForeignKey, FK_PartNo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment