SQLServer禁用、启用外键约束

表中含有外键而无法插入数据的解决办法:禁用外键约束

—启用or禁用指定表所有外键约束

alter table PUB_STRU  NOCHECK constraint all; 
alter table PUB_STRU  CHECK constraint all;  

–启用or禁用单个外键约束

ALTER TABLE PUB_STRU NOCHECK CONSTRAINT PUBSTRU_FK1;
ALTER TABLE PUB_STRU NOCHECK CONSTRAINT PUBSTRU_FK2;
ALTER TABLE PUB_STRU CHECK CONSTRAINT PUBSTRU_FK1;
ALTER TABLE PUB_STRU CHECK CONSTRAINT PUBSTRU_FK2;   

你可能感兴趣的:(SQL,Server学习笔记)