在触发器中如何按条件终止:
if ...    停止
else   执行

解决方案 »

  1.   

    if 满足你的条件  return
      

  2.   

    这是在触发器中的游标,不知哪有错
    Declare MyCursor Cursor for
    Select a.spno,a.spspec,a.weight,b.ddate from Deleted a,jhdmst b 
    where a.danno=b.danno 
    Open  MyCursor
    Fetch Next from MyCursor into @spno,@spspec,@weight
    While @@Fetch_Status=0
    begin
      update spkcd set weight = weight - @weight
      where spno=@spno and spspec = @spspec
      Fetch Next from MyCursor into @spno,@spspec,@weight
    end
    Close MyCursor
    DeAllocate MyCursor