Friday 15 June 2012

MS SQL Server - What is the value of WITH CHECK in a foreign key constraint? -


When I have a SQL Server Management Studio generating a table creation script for me, compared to foreign key constraints It is a bit different. They have to write

here is one:.

  ALTER Table [dbo] [GeoBytesCountries] Ed Barrier [FK_GeoBytesCountries_MapReferenceId] with foreign key reference ([MapReferenceId]) [dbo]. [GeoBytesMapReferences] ([MapReferenceId]) GO ALTER table [dbo]. [GeoBytesCountries] Check restrictions [FK_GeoBytesCountries_MapReferenceId] GO   

I did not write this foreign key barrier with "check" and expect to receive 2 "check restrictions" statement and the same functionality.

Can someone explain me the value of "with check" and a different "checking restriction" statement when you are writing the barrier to the foreign key for a table?

Or is the code above completely / functionally equivalent to code above?

  Alternate table [dbo]. [GeoBytesC (GRAIFIFI)] [[MapRiffFire ID]]    

The way I I see, the two-step approach allows you to fail at least "bad" data in the section in check with the "bad" data, that is your obligation to exist and to move forward from that point on DML Will apply, but you may have to do some cleaning on your current data so that it can be a reliable obstacle E

No comments:

Post a Comment