title: Procedure to award every 3rd person
body: <p>Im working on a stored procedure, which should reward every 3rd person with a extra bonus on his current credit. Amount of bonus and (3rd person) option should be parameterized. Among is a my current code, but when I try to execute this with SQLFiddle, I get always the error <code>Incorrect syntax near 'INTEGER'.</code> - but I can't find out the mistake in my code. I'm using MS SQL Server 2014. </p>
  
  <pre><code>    CREATE TABLE Customer (
          custnr      INTEGER PRIMARY KEY IDENTITY,
          name        VARCHAR(40) NOT NULL,
          firstname   VARCHAR(40) NOT NULL,
          credit      DECIMAL(12,2) 
      );
  
      CREATE PROCEDURE awardBonus
          @position       INTEGER;
          @bonus          DECIMAL(5,2) 
      AS 
      BEGIN
  
          DECLARE @creditCustomer DECIMAL(12,2);
          DECLARE customer_cursor CURSOR FOR 
          SELECT custnr 
          FROM Customer
          ORDER BY custnr ASC;
  
          OPEN customer_cursor;
  
          FETCH NEXT FROM customer_cursor INTO @custnr;
  
          WHILE @@FETCH_STATUS = 0    
              BEGIN
  
                  IF (@custnr % @position = 0) 
                      BEGIN 
                          SELECT @creditCustomer = credit 
                          FROM Customer 
                          WHERE custnr = @custnr;
  
                          SET @creditCustomer = @creditCustomer + @bonus;
  
                          UPDATE Customer 
                          SET credit = @creditCustomer
                          WHERE custnr = @custnr;
                      END; 
                  FETCH NEXT FROM customer_cursor INTO @custnr;
              END;
  
          CLOSE customer_cursor;      
          DEALLOCATE customer_cursor;
  
      END;
  
  EXECUTE awardBonus 3, 100
  </code></pre>