x
login about faq Site discussion (meta-askssc)

Alter Table Conflict

ALTER TABLE EA.TECHNOLOGY_UTILIZATION
ADD CONSTRAINT  TECHUTIL_FK_IT_1 
FOREIGN KEY (INFORMATION_TECHNOLOGY_ID) 
REFERENCES EA.INFORMATION_TECHNOLOGY(INFORMATION_TECHNOLOGY_ID)

go

when I execute this command I get this error

Msg 547, Level 16, State 0, Line 1
The ALTER TABLE statement conflicted 
with the FOREIGN KEY constraint "TECHUTIL_FK_IT". 
The conflict occurred in database 
"test_db", table "EA.INFORMATION_TECHNOLOGY", 
column 'INFORMATION_TECHNOLOGY_ID'.

I thought there is some dependency or exisitng already.. for safe side.. dropped the constraint.. then the error message said

Msg 3728, Level 16, State 1, Line 1
'TECHUTIL_FK_IT' is not a constraint.
Msg 3727, Level 16, State 0, Line 1
Could not drop constraint. See previous errors.

Any insight.. of the issue here?

more ▼

asked Mar 26 '10 at 01:20 PM in Default

Katie 1 gravatar image

Katie 1
1.4k 110 161 202

can you post the full scripted DDL of both tables?

Mar 26 '10 at 02:08 PM Kev Riley ♦♦
(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

I think the problem is that there are values in the TECHNOLOGY_UTILIZATIONADD column of INFORMATION_TECHNOLOGY_ID that aren't present in INFORMATION_TECHNOLOGY. Try this query to test:

select  *
from    EA.TECHNOLOGY_UTILIZATIONADD tu
    left join EA.INFORMATION_TECHNOLOGY it on it.INFORMATION_TECHNOLOGY_ID = tu.INFORMATION_TECHNOLOGY_ID
where   it.INFORMATION_TECHNOLOGY_ID is null

That will show you the offending rows. You'll have to fix them before you can add the constraint.

more ▼

answered Mar 26 '10 at 03:34 PM

David Wimbush gravatar image

David Wimbush
4.2k 25 29 31

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x1843
x916
x119
x107

asked: Mar 26 '10 at 01:20 PM

Seen: 1477 times

Last Updated: Mar 26 '10 at 01:47 PM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.