fix lỗi
click execute
alter table Works_On
add foreign key (PNo) references Project(PNumber)
xuất hiện lỗi
Msg 547, Level 16, State 0, Line 83
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK__Works_On__PNo__5070F446". The conflict occurred in database "SQLLab2", table "dbo.Project", column 'PNumber'.
click execute
alter table Works_On
add foreign key (PNo) references Project(PNumber)
xuất hiện lỗi
Msg 547, Level 16, State 0, Line 83
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK__Works_On__PNo__5070F446". The conflict occurred in database "SQLLab2", table "dbo.Project", column 'PNumber'.
lý do
Không đồng bộ dữ liệu giữ các bảng, xảy ra xung đột dữ liệu giữa 2 table data
fix:
thêm with nocheck vào sau tên bảng
alter table Works_On with nocheck
add foreign key (PNo) references Project(PNumber)
add foreign key (PNo) references Project(PNumber)
tham khảo: https://www.youtube.com/watch?v=dWd2zzRbxmc
Không có nhận xét nào:
Đăng nhận xét