当表中a,b 两列的值同时为1的时候 同表中的另一列c 的值 自动设成1 这个触发器怎么写 谢谢

解决方案 »

  1.   

    这个不用触发器就可以呀
    update table_name set c=1 where table_name.a=table_name.b and table_name.a=1
      

  2.   

    感谢hllmh(小狼)的回复
    能不能用触发器来实现?
      

  3.   

    create trigger trgInsert
    on table_name after insert
    as
        update table_name
        set c=1
        where a=1 and b=1
    gocreate trigger trgUpdate
    on table_name after update
    as
        update table_name
        set c=1
        where a=1 and b=1
    go
      

  4.   

    CREATE trigger triupdate on tb1 for  insert 
    as
    begin
    update tb1 
        set c=1
        where a=1 and b=1
    end