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
FORUM

Script to find Foreign Key missing Index?

Script to find Foreign Key missing Index?

SCRIPT

Script foreign keys

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

ARTICLE

Foreign Keys

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

SCRIPT

Generate index on foreign key columns

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

SCRIPT

Find Foreign Keys

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

 
Contribute