Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.
ALTER TABLE [dbo].[REMINDER_EMAIL]  WITH CHECK ADD  CONSTRAINT 
  [FK__REMINDER_EMAIL__FACILITY_ID] FOREIGN KEY ( [FACILITY_ID] )
  REFERENCES [dbo].[FACILITY] ( [FACILITY_ID] )

ALTER TABLE [dbo].[REMINDER_EMAIL] CHECK CONSTRAINT [FK__REMINDER_EMAIL__FACILITY_ID]

Thanks in advance for your help.

share|improve this question
1  
A simple search on this site could lead have you somewhere...check this link out: stackoverflow.com/questions/529941/… –  Michael Sep 24 '12 at 16:49
1  
@Michael Please don't add comments as answers, even if you don't have the necessary rep to post a comment. –  JNK Sep 24 '12 at 17:25
add comment

1 Answer 1

With foreign key and check constraints, specifying CHECK or NOCHECK enables or disables it. It's just explicit DDL that is generated by the GUI that, in your case, enables the foreign key constraint:

{ CHECK | NOCHECK } CONSTRAINT
Specifies that constraint_name is enabled or disabled. This option can only be used with FOREIGN KEY and CHECK constraints. When NOCHECK is specified, the constraint is disabled and future inserts or updates to the column are not validated against the constraint conditions. DEFAULT, PRIMARY KEY, and UNIQUE constraints cannot be disabled.

Reference: BOL ALTER TABLE

share|improve this answer
1  
The syntax does seem redundant though. I thought for sure it would have already been reported as a bug on connect.microsoft.com/sql but it's not there. Based on the priority they place on other "correct, but not 100% correct" scripting bugs, it's unlikely such a report would ever be fixed. –  Aaron Bertrand Sep 24 '12 at 17:19
1  
It is redundant and unnecessary, but I just take it as "verbose". If I was to defend it forcefully, I'd say it leaves the script reader without any question of functionality. –  Thomas Stringer Sep 24 '12 at 18:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.