且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

外键SQL Server 2016(MSG 1769)

更新时间:2023-01-30 11:35:11

您需要更改第二个函数,以确保在第二个表中创建要设置为外键的列.

You need to change the second function to make sure you create the column in the second table that you want to set as your foreign key.

尝试一下.

create table Courses (
    Course_code nvarchar(10) not null,
    Course_name nvarchar(20) not null,
    Major_name nvarchar(20) not null,
    primary key (Course_code),
    foreign key (Major_name) references Majors(Major_name)
)