Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Foreign Key DDL wizard

By cjm30305,

This script can be run when you want to do batch processing on a database, such as a dynamic truncate statement for all tables in your database.  This script will actually script all the Foreign Keys in your database, and then store them into a table called FOREIGN_KEY_TEMP.  It will then generate, and execute, all the ALTER TABLE statements needed to drop your foreign keys.  Then it will display the results, of the scripting done earlier to give you back your foreign keys.

Total article views: 203 | Views in the last 30 days: 1
Related Articles

Script to find Foreign Key missing Index?

Script to find Foreign Key missing Index?


Script foreign keys

Using this script you can create a list of sql commands for foreign keys manipulation.


Foreign Keys

Foreign keys are an important part of a relational database. New author Ravi Lobo takes a look at fo...


Generate index on foreign key columns

Script find all foreign key without index in database and create new one for them.


Find Foreign Keys

This script lists all foreign keys with parent and child table information


Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones