哥们没写过这东西
想实现这样的功能 就是 一个表中 有 4个字段 都是bit 类型 默认值 都为0 想让其中三个字段(固定的三个字段)为1时 另外一个自动变成 1 请问如何来实现 谢谢

解决方案 »

  1.   

    create trigger tr_表 on 表
    for insert,update
    as
    if exists(select 1 from inserted where 字段1=1 and 字段2=1 and 字段3=1)
    begin
    update 表
    set 字段4=1
    from 表, inserted i
    where 表.字段4=0 and i.字段1=1 and i.字段2=1 and i.字段3=1
    end
      

  2.   

    create trigger tr_tablename_update
    on tablename
    for update,insert
    asupdate a
    set 另外一个=1
    from tablename a,inserted i
    where a.关键字=i.关键字
    and a.固定1=1
    and a.固定2=1
    and a.固定3=1
    and a.另外一个=0go
      

  3.   

    楼上的兄弟  where a.关键字=i.关键字 这句什么意思啊  关键字指的是什么啊