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
 Transact-SQL (2000)
 Enable constraint

Author  Topic 

asyssolvers
Starting Member

9 Posts

Posted - 2011-04-21 : 12:40:33
Hi there,

I am having a huge database with many constraint and i have updated some data disabling constraint and I j't want to enable them back.

I have used below query
EXEC sp_msforeachtable 'ALTER TABLE MyTable NOCHECK CONSTRAINT all'
exec sp_msforeachtable @command1='print ''MyTable''', @command2='ALTER TABLE MyTable WITH CHECK CHECK CONSTRAINT all'

But when I run enable query it take long time due to huge volume of data. It take more than 1 hour.

I jt want to enable it quickly and proper way without having any issue.
Please guide me how to overcome this issue.

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-04-21 : 13:25:47
If you have multiple constraints on a table you may want to do one at a time, but ultimately it has to check all the data for violations, there's no real way to speed that up.
Go to Top of Page
   

- Advertisement -