Re: ALTER TABLE statement conflicted with COLUMN FOREIGN KEY

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Tom Moreau (tom_at_dont.spam.me.cips.ca)
Date: 09/09/04


Date: Thu, 9 Sep 2004 13:04:00 -0400

It will save you even more time if you simply provide the DDL for BOTH
tables. I cannot help you until you do that.

-- 
Tom
---------------------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"stoko" <stoko@discussions.microsoft.com> wrote in message
news:F2F57F9B-D3E5-4B47-A53E-4A2F2750E2FB@microsoft.com...
Tom,
It would have saved us some time if you renamed the tables to DEF.  The DDL
I sent are production tables.  I was trying to change the names, etc, but
decided to send you the live information.  Thus far, no one has been able to
help explain why I cannot delete and recreate constraints in a sp or script
or dts on tables that have records.  The irony is that this thing worked the
first few times and just fails thereafter -- requiring me to recreate the
constraints manually.
I am still waiting for your support.
Thanks.
Stoko.
"Tom Moreau" wrote:
> Actually, we really need the DDL for table dbo.DEF.
>
> -- 
>    Tom
>
> ----------------------------------------------------
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON   Canada
> www.pinnaclepublishing.com
> ..
> "stoko" <stoko@discussions.microsoft.com> wrote in message
> news:72208196-B2EE-4A61-B46C-0F9C7DA0AAE6@microsoft.com...
> Below is the info you requested.  Each time I drop the constraints via sql
> analyzer and try recreating them, I have the FK error.  I check via EM and
> the constraints are not there.  What must be going on is beyond my
> comprehension.  Initially, the first 4 attempts works fine but
there-after,
> nothing works.  Remember that the tables have data.
>
> Let me know...
> Thanks in advance.
> Stoko.
>
> "Tom Moreau" wrote:
>
> > Post your DDL for table dbo.DEF.
> >
> > -- 
> > Tom
> >
> > ---------------------------------------------------------------
> > Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> > SQL Server MVP
> > Columnist, SQL Server Professional
> > Toronto, ON Canada
> > www.pinnaclepublishing.com/sql
> >
> >
> > "stoko" <anonymous@discussions.microsoft.com> wrote in message
> > news:0ba901c48936$784343d0$3501280a@phx.gbl...
> > I got the following Error
> >
> > "ALTER TABLE statement conflicted with COLUMN FOREIGN KEY
> > constraint 'FK_ABC_DEF'. The conflict occurred in
> > database 'Test', table 'DEF', column 'ID'."
> >
> > when I ran the following scripts:
> >
> > if exists (select * from dbo.sysobjects where id =
> > object_id(N'[dbo].[FK_ABC_DEF]') and OBJECTPROPERTY(id,
> > N'IsForeignKey') = 1)
> > ALTER TABLE [dbo].[ABC] DROP CONSTRAINT FK_ABC_DEF
> > GO
> >
> >
> > ALTER TABLE [dbo].[ABC] ADD
> > CONSTRAINT [FK_ABC_DEF] FOREIGN KEY
> > (
> > [ID]
> > ) REFERENCES [dbo].[DEF] (
> > [ID]
> > ) ON DELETE CASCADE  NOT FOR REPLICATION
> > GO
> >
> >
> > My goal was to delete the constraint and recreate it but
> > the above error indicates that the FK constraint is still
> > active even when I verified on both tables and there were
> > not available.
> >
> > Is this a problem with sqlserver 2000 or the problem is me.
> >
> > Please help.
> >
> >
> >
>
>


Relevant Pages

  • Re: Unique index not recognizing null
    ... if they're not subject to the constraints of the Index?" ... consistent with other products - including SQL Server, Oracle, and how MS ... value in one or more of the key fields will not be included in the ... Nulls setting made no difference. ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Question on Structuring Product Attributes
    ... constraints, I have found a combination of features that allow for ... materialized-views that bring the data together, ... I have no experience with Oracle, ... feature SQL Server has) that joins data from subtype and supertype ...
    (comp.databases.theory)
  • Re: Use DEFAULT CONSTRAINTs or BOUND DEFAULTs?
    ... > I read SQL Server MVP Louis Davidson's post saying: ... > Constraints are the standard way to do this, and really should be the way ... > Even I read in the Microsoft SQL Server Introduction (SQL 7 book ... > DefaultZero ...
    (comp.databases.ms-sqlserver)
  • Re: Add columns to table, but in an order
    ... in the order that SQL Server mentions them, with no way for the end user ... existing constraints and recreate them when the new table is in place. ... be very critical of the script ... Make sure to test the conversion on a test server first. ...
    (microsoft.public.sqlserver.server)
  • Re: Disabling Constraint for Bulk Loading
    ... I am working on ASE 12.5 ... Are you using Sybase SQL Server or Microsoft ... to disable constraints the command is NOCHECK CONSTRAINT ALL. ...
    (comp.databases.ms-sqlserver)