i have a column (myColumn) that serves as the primary key of a table (tableA).
i’ve noticed that 2 or 3 tables reference this myColumn as foreign key.
how do i detect all tables that use and reference myColumn?
im guessing that more than 3 tables use myColumn because when i tried updating it like this
UPDATE tableA
SET myColumn = 1
WHERE myColumn = 1
6 rows were updated.
it was earlier suggested to me to use
sp_helpconstraint('your_table_name')
but i then found out that this does not give the complete information that i need.
any other suggestions?
Try this – this is the more up-to-date, SQL Server 2005 and newer version of my original answer that Mitch linked to (that was for SQL Server 2000):
It uses the system catalog views
sys.foreign_keysandsys.foreign_key_columnsto find out which tables/columns reference that table and column you’re interested in.You just basically type in the table name and the column name in the
WHEREclause – and you get your list of other tables/columns referencing that table/column