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
 General SQL Server Forums
 New to SQL Server Programming
 nocheck add constraint

Author  Topic 

mavericky
Posting Yak Master

117 Posts

Posted - 2011-09-26 : 17:12:16
Hi,
Can anybody tell the difference between nocheck constraint and check constraint?

For ex:
ALTER TABLE [dbo].[ServiceDeliveryPoint] WITH NOCHECK ADD CONSTRAINT [FK_ServiceDeliveryPoint_TransformerID] FOREIGN KEY([TransformerID])
REFERENCES [dbo].[BaseTransformer] ([ID])
GO
ALTER TABLE [dbo].[ServiceDeliveryPoint] CHECK CONSTRAINT [FK_ServiceDeliveryPoint_TransformerID]

What would be the difference if I used 'check add constraint' instead of 'nocheck add constraint'?

Thanks,
Mavericky

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-09-26 : 17:40:14
No difference, because the second statement does that - check for existing data that violates the constraint.

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -