I need to remove a highly referenced table in a SQL Server database. How can I get a list of all the foreign key constraints I will need to remove in order to drop the table?
(SQL answers preferable over clicking about in the GUI of the management studio.)
Try this :
I am using this script to find all details related to foreign key. I am using INFORMATION.SCHEMA. Below is a SQL Script:
First
Then use NimbleText to play with your results
Working off of what @Gishu did I was able to produce and use the following SQL in SQL Server 2005
Which Displays the tables, columns and Foreign Key names all in 1 query.
I have been using this on 2008 and up. It's similar to some other solutions listed but, the field names are proper cased to handle case specific (LatBin) collations. Additionally, you can feed it a single table name and retrieve just the info for that table.
This gives you:
Code below: