SQL Server Central is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
Search:  
 
 

Delete constraints - SQL Server 2005

By Toby Rogers, 2007/09/19

Total article views: 674 | Views in the last 30 days: 174

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

By Toby Rogers, 2007/09/19

Total article views: 674 | Views in the last 30 days: 174
Your response
 
 
Related tags

Miscellaneous    
 
Like this? Try these...

Get dependant Objects

By BeoWulf . | Category: T-SQL
(not yet rated) | 571 reads
Already registered?  

Free registration required

To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.

Register

E-mail address:
Password:
Password (confirm):

  

Subscriptions

We ask you to register on the site and subscribe to our newsletters. Subscribing to our newsletters gets you:

  • ALL of our content (thousands of articles, scripts, and forum postings)
  • A daily newsletter (example)
  • A weekly news round up (example)
  • The opportunity to ask and answer questions in our forums
  • A daily Question of the Day to test and help you increase your knowledge of SQL Server.

We ask that you give the newsletter a try for a week. Over 200,000 SQL Server Professionals a day find it entertaining and useful. If not, you are welcome to unsubscribe at anytime.

Steve Jones
Editor, SQLServerCentral.com