--要不这样???
--测试环境
create table a
(
a int primary key
)
go
create table b
(
a int primary key
)
go
create table c
(
id int identity primary key,
a int ,
constraint fk_a foreign key (a) references a(a) on delete cascade ,
constraint fk_b foreign key (a) references b(a) on delete cascade 
)
go--测试数据
insert a values(1)
insert a values(2)
insert a values(3)
insert b values(1)
insert b values(2)
insert b values(3)
insert c values(1)
insert c values(2)
insert c values(3)
select * from a
select * from b
select * from c
go
--测试
delete from a where a = 1
select * from a
select * from b
select * from c
go
delete from b where a = 2
select * from a
select * from b
select * from c
go

解决方案 »

  1.   

    --可以啊--创建a表
    create table a (a int primary key)
    go--创建c表
    create table c(c int primary key)
    go--创建b表
    create table b(a int not null,b int,c int not null
    ,constraint fk_b_a foreign key (a) references a(a) on delete cascade  --a与表a的a关联
    ,constraint fk_b_c foreign key (c) references c(c) on delete cascade --c与表c的c关联
    )go
    drop table b,a,c
      

  2.   

    --下面是测试:--创建a表
    create table a (a int primary key)
    go--创建c表
    create table c(c int primary key)
    go--创建b表
    create table b(a int not null,b int,c int not null
    ,constraint fk_b_a foreign key (a) references a(a) on delete cascade  --a与表a的a关联
    ,constraint fk_b_c foreign key (c) references c(c) on delete cascade --c与表c的c关联
    )
    go--插入测试数据
    insert into a
    select 1
    union all select 2
    union all select 3
    goinsert into c
    select 11
    union all select 22
    goinsert into b(a,c,b)
    select 1,11,1
    union all select 1,22,2
    union all select 2,22,3
    union all select 2,11,4
    union all select 3,11,5
    union all select 3,22,6
    go--显示表的内容
    select a.*,c.*
    from b 
    join a on a.a=b.a
    join c on c.c=b.c
    go--删除a表内容测试
    delete from a where a=1
    go--显示表的内容
    select a.*,c.*
    from b 
    join a on a.a=b.a
    join c on c.c=b.c
    go--删除c表内容测试
    delete from c where c=22
    go--显示表的内容
    select a.*,c.*
    from b 
    join a on a.a=b.a
    join c on c.c=b.c--删除测试环境
    drop table b,a,c/*--测试结果a           c           
    ----------- ----------- 
    1           11
    1           22
    2           22
    2           11
    3           11
    3           22(所影响的行数为 6 行)
    (所影响的行数为 1 行)a           c           
    ----------- ----------- 
    2           22
    2           11
    3           11
    3           22(所影响的行数为 4 行)
    (所影响的行数为 1 行)a           c           
    ----------- ----------- 
    2           11
    3           11(所影响的行数为 2 行)
    --*/
      

  3.   

    --楼主的SQL是7.0,就不支持此功能了,要改用触发器来完成--创建维护a,b之间关系的删除触发器
    create trigger t_delete on a
    for delete
    delete b from b join deleted d on b.a=d.a
    go--创建维护c,b之间关系的删除触发器
    create trigger t_delete on c
    for delete
    delete b from b join deleted d on b.c=d.c
    go