Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Alter Table Add Constraint Erro

Author  Topic 

Zath
Constraint Violating Yak Guru

298 Posts

Posted - 2007-03-01 : 15:29:11

2 Tables:

tblEquipments with field testTechnology(int)
tblTestTechnology with field id(int and primary key)
And tblTestTechnology has another field with text that goes w/id number

So, adding a constraint to tblEquipments....

ALTER TABLE [dbo].[tblEquipments] ADD CONSTRAINT FK_testTechnology_tblEquipments FOREIGN KEY (testTechnology)
REFERENCES tblTestTechnology (id)
I get the error:

ALTER TABLE statement conflicted with COLUMN FOREIGN KEY constraint 'FK_testTechnology_tblEquipments'. The conflict occurred in database 'myDatabase', table 'tblTestTechnology', column 'id'.

I have double checked and all the numbers in the tblEquipments field testTechnology exist - no blanks, and they exist in in the constraining table.

Why the error and what can I check?

Thanks,

Zath




Zath
Constraint Violating Yak Guru

298 Posts

Posted - 2007-03-01 : 15:33:58
Nevermind, found the problem


Zath
Go to Top of Page
   

- Advertisement -