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)

Drop and Add Foreign Keys

By steve block,

Have you tried using DTS to load a database and those pesky foreign keys mess you up? This is actually two scripts, one to generate the SQL needed to drop all the Foreign Keys in a database and another to Add the Foreign Keys back when you are done. I've thrown in Disabling and Enabling Triggers as a bonus.

Run the scripts in Query Analyzer with 'Results to text'. Once either script runs, save the results in a .sql file.

Assumption: all objects are owned by dbo

Total article views: 2860 | Views in the last 30 days: 9
 
Related Articles
SCRIPT

Script foreign keys

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

FORUM

Script to find Foreign Key missing Index?

Script to find Foreign Key missing Index?

BLOG

Script Out Foreign Keys With Multiple Keys

It's easy enough to use sys.foreign_keys and sys.foreign_key_columns to identify foreign keys.  But ...

SCRIPT

Find Foreign Keys

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

ARTICLE

Foreign Keys

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

Tags
 
Contribute

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
Editor, SQLServerCentral.com

Already a member? Jump in:

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