Hello ,
If you are using SQL 7.0 , then there is a bug in sql 7.0 ,
BUG #: 54921 (SQLBUG_70)
SYMPTOMS
========
If the following sequence of events occurs the system fails to check the
constraint for new data modifications:
1. An ALTER TABLE statement is issued WITH NOCHECK constraint on a foreign
key.
2. A row is deleted.
3. The table is altered back with check constraint on the foreign key.
WORKAROUND
==========
To work around this problem, use either of the following:
- Stop and restart SQL Server after re-enabling the check constraint.
-or-
- Execute DBCC FREEPROCCACHE after re-enabling the check constraint.
SQL 7.0 SP2 Fixes this problem.
Thanks,
Vikrant Dalwale
Microsoft SQL Server Support Professional
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.? 2002 Microsoft Corporation. All rights
reserved.
Additional support can be obtained at http://support.microsoft.com
Are you secure? For information about the Strategic Technology Protection
Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.
--------------------
>Newsgroups: microsoft.public.sqlserver.programming
>Subject: checking the violation of constraint with existing data (after
enabling of the constraint)
>Date: 20 May 2002 05:38:09 -0700
>Organization: http://groups.google.com/
>Lines: 22
>NNTP-Posting-Host: 203.124.129.101
>Content-Type: text/plain; charset=ISO-8859-1
>Content-Transfer-Encoding: 8bit
>X-Trace: posting.google.com 1021898290 12625 127.0.0.1 (20 May 2002
12:38:10 GMT)
>NNTP-Posting-Date: 20 May 2002 12:38:10 GMT
>Path:
cpmsftngxa08!tkmsftngp01!newsfeed00.sul.t-online.de!t-online.de!news-spur1.
m
axwell.syr.edu!news.maxwell.syr.edu!out.nntp.be!propagator2-SanJose!propagat
or-SanJose!in.nntp.be!easynews!sn-xit-02!supernews.com!postnews1.google.com!
not-for-mail
Quote:>Xref: cpmsftngxa08 microsoft.public.sqlserver.programming:259420
>X-Tomcat-NG: microsoft.public.sqlserver.programming
>Hi,
>temp1.i refers temp.i.
>I disable this foriegn key constraint using
>alter table tt1 nocheck constraint all
>alter table tt1 check constraint all
>and add some data in temp1 (which is not in temp.i)
>after adding some data i enable the constraint
>but it doesn't throw a error for the existing data, which violates the
>foreign key constraint
>Is it possible that after i enable the constraint it should check
>whether the existing data violates the constraint or not ?
>Hope i am clear with my problem
>TIA
>~Parvinder