title: Why is my ELSE Statment Is giving me a ERROR?
body: <p>I'm Trying to Create a stored procedure.The procedure should take two parameters, the invoice id and the amount of payment. Update that record to add this payment to the total and record the payment date as today.This Is the code I'm using this code.If any other errors are seen please point them out.</p>
  
  <pre><code>USE AP;
  IF OBJECT_ID ('spRecordPayment') IS NOT NULL
  DROP PROC spRecordPayment;
  GO
  
  CREATE PROCEDURE spRecordPayment
   @InvoiceID int,
   @PaymentAmount money
  AS
  
  BEGIN
  SELECT InvoiceId,InvoiceTotal
  FROM Invocies
  WHERE InvoiceId = @InvoiceID
      IF @PaymentAmount &gt; InvoiceTotal
          DECLARE @CreditTotal MONEY;
          SET @CreditTotal = @PaymentAmount - InvoiceTotal;
  
          UPDATE Invoices
          SET CreditTotal = @CreditTotal
          WHERE InvoiceID = @InvoiceID;
  
          UPDATE Invoices
          SET PaymentDate = GETDATE()
      ELSE --This is Line 21
  
       DECLARE @CreditTotal2 MONEY;
       SET @CreditTotal2 = InvoiceTotal - @PaymentAmount;
  
       UPDATE Invoices
       SET CreditTotal = @CreditTotal2
       WHERE InvoiceID = @InvoiceID;
  
       UPDATE Invoices
       SET PaymentDate = GETDATE()
  END
  </code></pre>
  
  <p>It Gives Me This Error:</p>
  
  <blockquote>
    <p>Msg 156, Level 15, State 1, Procedure spRecordPayment, Line 21
    Incorrect syntax near the keyword 'ELSE'.</p>
  </blockquote>