idno,stuff,manpower,process,produce,costtime,wastage是material中的字段

解决方案 »

  1.   

    执行完UPDATE再执行INSERT不可以吗?
    不用CASE吧?
      

  2.   

    对啊,先UPDATE 后在INSERT了,分两条语句
    CREATE TRIGGER [updateday] ON [dbo].[Material] 
    FOR  UPDATE
    AS
    if update(stuff) or update(manpower) or update(produce) or update(process)
      begin
        update material 
        set editstan=case when standard=0 then getdate() 
                          else editstan end,
            standday=case when standard=0 then getdate() else standday end,
            standard=stuff+manpower+produce+process   insert costhist(goodsid,stuff,manpower,process,
                       produce,editstan,costtime,wastage)
       select idno,stuff,manpower,process,produce,
              getdate(),costtime,wastage
       from inserted where ifset = 0
    end