哦,不好意思。
条件是table1.zd0等于table2.zd0应该是这样。。

解决方案 »

  1.   

    对了table1.zd0(int)
    table2.zd0(int)
      

  2.   

    create trigger on table2 for insert
    as
    if (select zd1 from table1 where zd0=(select zd0 from inserted))>=(select zd2 from inserted)
         update table2 set zd5=zd3+cast(zd4 as varchar),zd4=zd4+1
         where zd0 = (select zd0 from inserted)
    else
         update table2 set zd6=zd3+cast(zd4 as varchar)
         where zd0 = (select zd0 from inserted)
      

  3.   

    哈哈,i have a try and latter see you .3x 这个东西完整吗??
      

  4.   

    create trigger T_name on table2
    for insert 
    as
    select table1.zd1 from table1 where table1.z0= table2.z0
    go
    select table2.zd2 from table2 where table2.z0=table1.z0
    goif (select table1.zd1 from table1 where table1.z0=table2.z0)>(select table2.zd2 from table2 where table2.z0=table1.z0)     
      begin  
      update table2 set table2.zd5=(select table2.zd3+table2.zd4 from table1,table2 where table2.z0=table1.z0)
      where table1.zd1=table2.zd2
      update table2 set table2.zd4=table2.zd4+1
      else
      update table2 set table2.zd6=(select table2.zd3+table2.zd4 from table1,table2 where table2.z0=table1.z0)
      where table1.zd1=table2.zd2
      end
    go靠!写的好费劲,还不知道对不对。
    兄弟就这点思路了
      

  5.   

    CREATE TRIGGER 名 on table2
    INSTEAD OF INSERT
    AS
    insert table2 (zd0,zd2,zd5,zd6,zd4,zd3) select a.zd0,a.zd2,
    case when b.zd1>=a.zd2 then a.zd3+cast(a.zd4 as varchar(10)) end,
    case when b.zd1<a.zd2 then a.zd3+cast(a.zd4 as varchar(10)) end,
    case when b.zd1>=a.zd2 then a.zd4+1 end,zd3
      from inserted a join table1 b on a.zd0=b.zd0