a 的表中是 a_ID
b 的表中是 b_ID
b表中的b_ID 是根据a表中a_ID的
 也就是说他们的关系就是 a_ID=b_ID的
并且要a.id=b.id=传过来的id 

解决方案 »

  1.   

    --用触发器
    create trigger my_trigger on a
    for delete
    asdelete from b where b_id in (select a_id from deleted)
      

  2.   


    delete a where a_id=@id
    delete b where b_id=@id
      

  3.   

    b表中的b_ID 是根据a表中a_ID的,
    先删B再删A吧.
      

  4.   

    if object_id('tb')is not null drop table tb
    if object_id('ta')is not null drop table ta
    go
    create table ta(ID int unique,[Name] varchar(10))
    insert ta select 1,'A'
    insert ta select 2,'B'
    create table tb(Aid int  foreign key references ta(ID ) on delete cascade,Meno varchar(10))
    insert tb select 1,'test1'
    insert tb select 2,'test2'
    go
    delete ta where id=2
    select * from tb
    /*Aid         Meno       
    ----------- ---------- 
    1           test1
    */