From the Object Explorer in SQL Server, when selecting and scripting a foreign-key constraint, the following code is generated.
USE [MyTestDatabase]
GO
ALTER TABLE [dbo].[T2] WITH NOCHECK ADD CONSTRAINT [FK_T2_T1] FOREIGN KEY([T1ID])
REFERENCES [dbo].[T1] ([T1ID])
GO
ALTER TABLE [dbo].[T2] CHECK CONSTRAINT [FK_T2_T1]
GO
What is the purpose of the last statement "ALTER TABLE CHECK CONSTRAINT"? It doesn't seem to matter whether or not it is run. It does not fail on existing bad data, nor does it change that the constraint will be enforced on new data.
Thanks!