以MS SQL Server中的pubs数据库中的authors和titleauthor表为例
两个表都有主键关联(au_id)怎样才能做添加记录,删除记录最好能附源码不甚感激

解决方案 »

  1.   

    用insert 和 DELETE 语句,添加删除了!!!
    源码看,SQL帮助了
      

  2.   

    authors 与  titleauthor 是依赖关系
      

  3.   

    delete from authors(or titleauthor) where au_id='###'
      

  4.   

    表间有依赖关系,用delect和insert单独对某一表进行处理 无法完成操作
      

  5.   

    delete from titleauthor where au_id='###'
    delete from authors where au_id='###'
    先删titleauthor表中数据,再删authors表中数据.
    或者你在SQL数据库中编一个触发器
    CREATE TRIGGER [aaa] ON titleauthor  
    FOR DELETE 
    AS
    declare @i as int
    set @i=(select au_id from deleted)
    delete oswxh where au_id=@iinsert添加的话还牵涉到别的表,要从关联最少的开始添加
      

  6.   

    上面触发器最后一行应为delete authors where au_id=@i