Please Pass your table name
To find out all references used in tables
select A.name as ForiegnKeyTable,
B.name as ForeignKeyColumn
from sys.foreign_key_columns as C
inner join sys.tables as A on C.parent_object_id = A.object_id
inner join sys.columns as B on C.parent_object_id = B.object_id and
C.parent_column_id = B.column_id
where C.referenced_object_id = (select object_id from sys.tables
where name = '<Table Name>')
order by ForiegnKeyTable
To find out all references used in tables
select A.name as ForiegnKeyTable,
B.name as ForeignKeyColumn
from sys.foreign_key_columns as C
inner join sys.tables as A on C.parent_object_id = A.object_id
inner join sys.columns as B on C.parent_object_id = B.object_id and
C.parent_column_id = B.column_id
where C.referenced_object_id = (select object_id from sys.tables
where name = '<Table Name>')
order by ForiegnKeyTable
0 comments:
Post a Comment