Double condition in t-sql



  • Tell me what's the right syntax of the 2nd condition in t-sql. You know,

    if ((условие 1 ) или (условие 2 ) ) 
    Begin 
    end 
    

    Here's my code:

    Create trigger mytrigger
        on Report 
        for Update, Insert
        as
            if  Update(salary) or  Insert(salary)
            BEGIN
    
            if exists 
                (Select * from inserted  i 
                join deleted  d
                on
                i.ReportID=d.ReportID
                where i.salary>d.salary
                or
                i.salary<1000
                )
            BEGIN
                RAISERROR('маленькая зп ',1,2)  
                ROLLBACK TRAN
            END
        END 
    

    I tried it again. if Update(salary) , Insert(salary)None of it works. Help!



  • Syntaxis is right:

    if (условие 1) OR (условие 2)
    begin 
    end 
    

    However, the functions of the trigger INSERT(colunm) No. Actually, in this case OR No need. Trigger function https://msdn.microsoft.com/en-us/library/ms187326.aspx It works. insert and, update

    create trigger mytrigger
    on Report
    for Update, Insert
    as
    begin
        set nocount on;
    
    if Update(salary)
    BEGIN
        print('do something');
    END;
    

    end




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2