创建外键约束的问题!
create table dbo.a
(id int identity(1,1) primary key nonclustered,
name varchar(10) not null,
sortid int not null foreign key references dbo.b(sortid)
)
create table dbo.b
(sortid int not null,
color varchar(20) not null
)
服务器: 消息 1767,级别 16,状态 1,行 1
外键 'FK__a__sortid__0A9D95DB' 引用了无效的表 'dbo.b'。
服务器: 消息 1750,级别 16,状态 1,行 1
未能创建约束。请参阅前面的错误信息。
我就想a的sortid是b的外键,哪错了??!!!