Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Disable all contraints of a given database

Author  Topic 

SQLCode
Posting Yak Master

143 Posts

Posted - 2004-02-18 : 10:52:14
Hi,
Is there any quick way of disabling all the constraints and triggers of the database for a quick append of data, assuming the data is good with all the integrity.

TIA

safigi
Starting Member

15 Posts

Posted - 2004-02-18 : 11:12:31
exec sp_msforeachtable 'alter table ? nocheck constraint all '
exec sp_msforeachtable 'alter table ? disable trigger all '

Safi
Go to Top of Page

SQLCode
Posting Yak Master

143 Posts

Posted - 2004-02-18 : 11:23:25
Ahaa! Thanks a lot. Also, I found out that while enabling them back we can also print the name of the object.
Here goes :
sp_msforeachtable @command1="print '?'", @command2="ALTER TABLE ? CHECK CONSTRAINT all"
sp_msforeachtable @command1="print '?'", @command2="ALTER TABLE ? ENABLE TRIGGER all"
Go to Top of Page
   

- Advertisement -