为什么不是直接
把需要发送的信息存放倒表一flag置为0,发送程序从表一取走数据后把记录删除,触发器同时把该记录插入表二。
这样flag字段都没必要要了

解决方案 »

  1.   

    如果是我说的做法:
    create trigger tr_send_delete
    on send
    for delete
    asinsert lsend(smid,scontent,inserttime,sendtime,destaddress)
    select smid,scontent,inserttime,sendtime,destaddress from deletedgo如果一定要你自己的做法:create trigger tr_send_update
    on send
    for update
    as
    if update(flag)
    begin
        insert lsend(smid,scontent,inserttime,sendtime,destaddress)
        select i.smid,i.scontent,i.inserttime,i.sendtime,i.destaddress from deleted d,inserted i 
        where i.smid=d.smid
        and i.flag=0
        and d.flag=1    deleted send
        from inserted i,deleted d
        where i.smid=d.smid
        and i.flag=0
        and d.flag=1
        and i.smid=send.smid
    end
    go
      

  2.   

    to  Rewiah(乘长风)你好,我照着你的做了,现在如果通过手工更改send表flag,能够执行相应的动作,但是如果通过应用程序update,send表的flag字段就不会执行相应的动作!不知道为什么?都同样是update为什么通过应用程序update不行呢?