日期:2014-05-17  浏览次数:20884 次

SQLserver 怎么设置删除主键连同外键数据一起删除啊
SQLserver  怎么设置删除主键时连同外键数据一起删除
顺便介绍两个C#的学习群  谢谢

------解决方案--------------------
本帖最后由 bdmh 于 2013-03-05 16:24:35 编辑
http://blog.csdn.net/xys_777/article/details/5689397
我记得2000中可以设置,象access中一样,现在的版本不清楚,很少用
------解决方案--------------------
create table tba(id主键 int not null primary key);
create table tbb(id主键 int not null primary key, tbaid int,
constraint FK_A foreign key(tbaid) references tba(id主键) on delete cascade);
------解决方案--------------------
级联删除就行:在删除主表时,自动删除副表(外键约束)相应内容