title: How to debug why a database trigger is not working?
body: <p>My first two <code>IF</code> statements work just fine (I've tested them), but for some reason the <code>ELSE IF</code> statement won't fire. I've tried different setups for the entire <code>ELSE IF</code> statement, different  arrangements with the <code>@DiscountPercent</code>, and putting the <code>IF</code> statements in a different order, but nothing works. It all results in .3 when it needs to be 30. Can someone please point me in the direction of where I can learn about what I'm doing wrong?</p>
  
  <pre><code>USE MyGuitarshop
  
  GO
  
  CREATE TRIGGER Products_UPDATE
      ON Products
      FOR UPDATE, INSERT
  
  AS
  
  DECLARE
      @DiscountPercent int;
  
  BEGIN
  
  SET @DiscountPercent = (SELECT DiscountPercent FROM INSERTED);
  
  IF @DiscountPercent &lt; 0
      BEGIN
          ROLLBACK TRANSACTION;
          THROW 528732,'Discount Percent cannot be less than 0.',1;
      END;
  
  IF @DiscountPercent &gt; 100 
      BEGIN
          ROLLBACK TRANSACTION;
          THROW 528733,'Discount Percent cannot be greatter than 100%.',1;
      END;
  
  ELSE IF @DiscountPercent &lt; 1 
          UPDATE Products
              SET @DiscountPercent = ((SELECT DiscountPercent FROM INSERTED) * 100)
              WHERE ProductID IN (Select ProductID FROM Inserted);
  
  END;
  
  GO
  
  UPDATE Products
      SET DiscountPercent = .3
          WHERE ProductID = 1;
  
  GO
  
  USE MyGuitarShop
  
  SELECT * FROM Products
  </code></pre>