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 |
|
hasanali00
Posting Yak Master
207 Posts |
Posted - 2006-04-16 : 14:49:31
|
| I wonder if you could help me with this problem:I have 2 tables:Categories (CategoryID primary key (int)....)Categories_Companies (RecordID primary key (int), CategoryID (int), CompanyID (int)As you can see, CategoryID in Categories_Companies is a Foreign Key.Now, in SQL Enterprise Manager, I create a new Diagram and add the above tables to the diagram, and cretae a relationship between these two tables. However, When I try to save the diagram, I get the folowing error:'Categories' table saved successfully'Categories_Companies' table- Unable to create relationship 'FK_Categories_Companies_Categories'. ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]ALTER TABLE statement conflicted with COLUMN FOREIGN KEY constraint 'FK_Categories_Companies_Categories'. The conflict occurred in database 'OnlineDB_Diagrams', table 'Categories', column 'CategoryID'.As I dont know much about creating relationship, I would be grateful if someone can help me on this issue.Kind regards |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-04-16 : 15:05:40
|
| It's saying that there is a CategoryID value in Categories_Companies that isn't in Categories and so cannot create the foreign key.run the queryselect distinct CategoryID from Categories_Companies where CategoryID not in (select CategoryID from Categories )==========================================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. |
 |
|
|
hasanali00
Posting Yak Master
207 Posts |
Posted - 2006-04-16 : 16:23:53
|
| Thanks alot |
 |
|
|
|
|
|