SQL Server adding foreign key: the column in the prompt table does not match the existing primary key or UNIQUE constraint

I. Overview

SQL Server adds a foreign key: the column in the prompt table does not match the existing primary key or UNIQUE constraint, as follows:

 

Two, the solution

What must be satisfied is the primary key of this table and the foreign key of another table, that is, the fields in the table of the foreign key are common.

View the primary key of table 6 is id

 Therefore, Table 6 should select the primary key Id to establish a foreign key relationship with Table 4, as shown below

 

Guess you like

Origin blog.csdn.net/chentiebo/article/details/131098482