query to get foreign key constraint names in the database using INFORMATION_SCHEMA

Bandi
Posted by Bandi under Sql Server category on | Points: 40 | Views : 550
Why the Foreign Keys(FK) list is required means

In development environment, frequently the DB developers have to do clean up of database and recreation of data; In these scenarios we need to delete the child table's data first, then need to get the hierarchy of child tables, later we need to script the code to delete data one-by-one.....

And there are so many scenarios to get the FK list such as the dependant tables list preparation; troubleshooting the database/table issues etc

SELECT * FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE  WHERE CONSTRAINT_NAME LIKE 'FK %'

Comments or Responses

Login to post response