SQL Server Referential Integrity - One-To-Many relationship
Posted on 2004-11-21
I get the following error when I try to create and save a new relationship between Companies and Trades tables (Companies.ID links to Trades.CompanyID)
'Companies' table saved successfully
- Unable to create relationship 'FK_Trades_Companies'.
ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]ALTER TABLE statement conflicted with COLUMN FOREIGN KEY constraint 'FK_Trades_Companies'. The conflict occurred in database 'XXXXXXX', table 'Companies', column 'ID'.
There is a one to many relationship between Companies and Trades. All trades have a company, but some companies have no trades.
All references in Trades.CompanyID exist in Companies.ID.
Is the problem because some companies have no related trades?
In Access, there is an option to specify the join type when creating referential integrity links. Is there something similar with SQL Server?