Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
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: 513 | 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


Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones