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)

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: 4007 | Views in the last 30 days: 14
 
Related Articles
SCRIPT

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

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

BLOG

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...

FORUM

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

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

SCRIPT

Generate DDL script to drop table constraints

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

FORUM

Constraints

Constraint with a check

Tags
miscellaneous    
 
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