Click here to monitor SSC
SQLServerCentral is supported by Redgate
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...


Script to Generate Foreign Keys

Generate Script for existing Foreign Keys for any emergency.


Generate index on foreign key columns

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