Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Detect invalid FK-data after using "WITH NOCHECK"

By Johan Bijnens,

In situations where FK's have been created using the "WITH NOCHECK" option you can get into troubles because the FK-data is not checked ! (so there may be invalid data in the FK-column !)

E.g. ALTER TABLE [dbo].[mytable] WITH NOCHECK add constraint [FK__USED_RESO__Actio__1162CF5F] FOREIGN KEY ( Action_Type ) REFERENCES [dbo].[Action_Types] ( Action_Type )

BOL states "... If you do not want to verify new CHECK or FOREIGN KEY constraints against existing data,
We do not recommend doing this, except in rare cases. ..."

I've commented the proc because I found the DBCC command that does even more than that !

Total article views: 515 | Views in the last 30 days: 1
Related Articles

History actions

History actions


Analysis Services 2005 Drillthrough Action

AS 2005 Drillthrough Action / Rowset Action


SSAS cube actions

cube actions in SSAS cube


Session Action Metadata

In a previous article, I introduced the core concept of Actions. In that article, I explained that a...


Drillthrough Actions

Customization of Data Sample View in Drillthrough Action