Blootac
Blootac

Reputation: 543

sql server check constraints

Am I missing something? When I get SSMS to script a check constraint for create it produces two statements,

ALTER TABLE mytable  WITH CHECK ADD  CONSTRAINT [CK_myconstraint] CHECK  (([Time]>='2011-05-15 20:33:00.000' AND [Time]<='2011-05-17 20:31:00.000'))
GO
ALTER TABLE mytable CHECK CONSTRAINT [CK_myconstraint]

My understanding is that the "with check" should check the constraint on existing data when the constraint is being made. If this is true, why is it then checking the constraint again?

Thanks

Upvotes: 1

Views: 270

Answers (1)

gbn
gbn

Reputation: 432180

You are correct, you only need the first one.

Don't know why SSMS does this. I thought maybe this was some permutation of "Scripting" options under Tools..Options, but I don't see anything likely

Upvotes: 3

Related Questions