Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 3
    A word of warning regarding what cyberwiki said. In general do not use "ALTER TABLE t1 CHECK CONSTRAINT fk". Always use ALTER TABLE t1 WITH CHECK CHECK CONSTRAINT fk unless you plan to disable and reenable the constraint again straight away. The WITH CHECK makes a huge difference because without it the constraint will be marked as "not trusted". That means the optimizer will ignore it and some other features may be affected or disabled (some view updates may not work for example). Commented Jan 18, 2011 at 14:13
  • @dportas - if you follow the question, and the next statement "leaves existing data alone" you will see why WITH CHECK doesn't work Commented Jan 18, 2011 at 18:37
  • @cyberwiki, sure. But the original request was to drop the rows that cause the errors. My understanding being that that Ben intends to correct the data before re-enabling the constraint, I just though it important to point out the disadvantage of re-enabling the constraint without WITH CHECK. Commented Jan 18, 2011 at 18:41