Search
 
SCRIPT & CODE EXAMPLE
 

SQL

sql server find all foreign keys that reference a column

SELECT 
   OBJECT_NAME(f.parent_object_id) TableName,
   COL_NAME(fc.parent_object_id,fc.parent_column_id) ColName
FROM 
   sys.foreign_keys AS f
INNER JOIN 
   sys.foreign_key_columns AS fc 
      ON f.OBJECT_ID = fc.constraint_object_id
INNER JOIN 
   sys.tables t 
      ON t.OBJECT_ID = fc.referenced_object_id
WHERE 
   OBJECT_NAME (f.referenced_object_id) = 'YourTableName'
Comment

PREVIOUS NEXT
Code Example
Sql :: sql pick random row 
Sql :: check all sequences oracle sql 
Sql :: mysql count lines 
Sql :: xampp mysql database not starting 
Sql :: show user mysql 
Sql :: drop db syntax 
Sql :: oracle alter sequence restart start with 
Sql :: mysql get random row 
Sql :: sql missing records from another table 
Sql :: oracle detect invalid password 
Sql :: mysql id reset 
Sql :: set statiscis on in ssms 
Sql :: tsql try catch 
Sql :: postgres update column with value from another table 
Sql :: mysql show table column full description 
Sql :: create user mysql 
Sql :: bigquery get current date 
Sql :: Aqua Data studio postgresql ssl 
Sql :: sql set no lmit 
Sql :: delete top 100 rows in sql server 
Sql :: get ddl materialized view oracle 
Sql :: update in sql 
Sql :: create another table from existing table sql oracle 
Sql :: sql server count all tables rows 
Sql :: SQL server query column yes or no 
Sql :: postgres make sql dump 
Sql :: get first 3 letters name in sql 
Sql :: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client 
Sql :: postgres count string length 
Sql :: sql last 3 rows 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =