Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Error creating relationship between tables
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Conception bases de données
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01091947
Message ID:
01092039
Vues:
16
This message has been marked as the solution to the initial question of the thread.
Evan,

You probably have a detail record that doesn't have a corresponding record in the header table. You will have to find the orphan record and fix it before SQL server will allow you to create the constraint.

Try the following SELECT statement to identify the orphan so you can fix it accordingly:
SELECT *
   FROM clinsdet t0
   LEFT JOIN clinserv t1
     ON t0.id = t1.id
   WHERE t1.id IS NULL
Kurt
>In the database diagram tool, I am attempting to creat a relationship betwen two tables. When I look at the constraints for both tables, I there are none listed. Clinserv is the parent table with a 1 to many relationship with the child table clinsdet. Clinsdet.fk_clinserv is a field with an index on it (IE the foreign key). I want to relat this to clinserv.id which is a primary key. I can drap clinsdet.fk_clinserv and drop it onto clinserv.id. When I save the diagram I get the following error.
>
>
>'clinserv' table saved successfully
>'clinsdet' table
>- Unable to create relationship 'FK_clinsdet_clinserv'.
>The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_clinsdet_clinserv". The conflict occurred in database "ecpvgh", table "dbo.clinserv", column 'id'.
>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform