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.
| Author |
Topic |
|
Ken Blum
Constraint Violating Yak Guru
383 Posts |
Posted - 2004-08-20 : 12:59:51
|
| I am attempting to setup a relation between 2 tables using a composite index. The tables are named Chemicals (child) and Container (parent). When I attempt to save the table changes I get the following error:/* Friday, August 20, 2004 11:50:46 AM User: Server: DOBCOGNOS Database: ChemWatch Application: MS SQLEM - Data Tools */'container' table saved successfully'chemicals' table- Unable to create relationship 'FK_chemicals_container'.ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]ALTER TABLE statement conflicted with TABLE FOREIGN KEY constraint 'FK_chemicals_container'.The conflict occurred in database 'ChemWatch', table 'container'.The thing is that there is not any constraint or relation in either the chemicals or container table that reference each other. The FK_chemicals_container is the name that I am attempting to save. I changed the name, & it still conflicts with itself.I should note that I made an error when designing a diagram where I attempted to make 2 relations between these tables, but the changes were never saved. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-08-20 : 13:13:41
|
| Could you post the DDL that is giving you the problem? Also, the DDL for the tables that includes all constraints?Tara |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-08-20 : 13:21:46
|
| >> there is not any constraint or relation in either the chemicals or container table that reference each other. You are trying to change a table structure and it is failing due to the foreign key FK_chemicals_container.It looks like the foreign key is already there and your change is affecting the relationship - but if you say it isn't then maybe you are trying to add it.trysp_help containersp_help chemicals_containerselect * from sysobjects where name = 'FK_chemicals_container'==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
Ken Blum
Constraint Violating Yak Guru
383 Posts |
Posted - 2004-08-20 : 13:23:14
|
DOH! The child table had some nulls in it so the enforcement was failing at creation of the constraint. I guess that's what it means when you have a constraint that conflicts with itself. Had me going for awhile! |
 |
|
|
|
|
|