你需要在在已下生产通知明细表上建两个触发器
一个insert,update
可以使用inserted系统临时表
一个delete
可以使用deleted系统临时表语法看看帮助
业务你清楚

解决方案 »

  1.   

    我是这样写的,不知行不行:
    CREATE TRIGGER [produce_project_detail delete] ON [dbo].[produce_project_detail] 
    FOR  DELETE 
    AS
    if (select count(*) 
        from noproduce_informdetail,deleted d 
      where noproduce_informdetail.orderformid=d.orderformid and   
      noproduce_informdetail.orderformitem=d.orderformid)=0
        begin 
           INSERT INTO .....
        end else
           update......
      

  2.   

    UP,不知我那句COUNT写得对不对,在末下生产通知单中,以订单号和订单明细项为主键!
      

  3.   

    count(*)... =0 是对的,但是最好写成
    CREATE TRIGGER [produce_project_detail delete] ON [dbo].[produce_project_detail] 
    FOR  DELETE 
    AS
    if not exists (select 1 
        from noproduce_informdetail,deleted d 
      where noproduce_informdetail.orderformid=d.orderformid and   
      noproduce_informdetail.orderformitem=d.orderformid)
        begin 
           INSERT INTO .....
        end 
        else
        begin
           update......
        end
      

  4.   

    老兄,你那个是SELECT L,还是SELECT 1