我正在尝试将Roomtype primary key
作为foreign key
插入Room表格,但会向我显示以下错误
主要错误0x80040E11,次要错误0
CREATE TABLE Room (
RoomID nvarchar(8),
Capacity numeric(3),
CONSTRAINT FK_TYPE foreign key (Roomtype) references RoomType(Roomtype)
)
Invalid column ID. [ Roomtype ]
CREATE TABLE Room (
RoomID nvarchar(8) ,
Capacity numeric(3),
CONSTRAINT FK_TYPE foreign key (Roomtype) references RoomType(Roomtype)
)
create table RoomType(
Roomtype nvarchar(2) primary key,
Description nvarchar(20),
Responsibility nvarchar(20)
)
答案 0 :(得分:2)
您需要在Room表中添加roomtype列。您正在为不存在的列创建外键
inputs