SQL Clone
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)

Delete constraints - SQL Server 2005

By sqldummy79,

This script will DELETE ALL constraints within the database that you define and in the following order: Foreign Key, Primary Key and then Unique Key.

CAUTION:This script does not print out the ALTER TABLE statements, it drop the constraints immediately, therefore backup your database before testing or using this script.

I ran the script below and it deleted 591 constraints in about 2 minutes.

I created and tested this script on SQL Server 2005, I don't know if it will work on SQL 2000

Total article views: 4011 | Views in the last 30 days: 14
Related Articles

Columns Explorer - With constraints create / drop scripts (no cursors)

Gets all columns infos, foreign keys (multicolumn fk handled), referenced primary keys, default and ...


A Script A Day - Day 15 - Untrusted Check Constraints

Today‚Äôs script comes about because of a recent discussion about check constraints.  The discussion w...


Script to Rename the indexes, Foreing Key Constraints using SQL Server 2005

Script to Rename the indexes, Foreing Key Constraints using SQL Server 2005


Generate DDL script to drop table constraints

Execute SP to generate alter statements to drop PK, FK, Check Constraints and Default Constraints on...


Constraints renaming

Rename constraints to enforce naming conventions.