title: Dynamic add column with loop
body: <p>I'd like to create a dynamic procedure wich will generate the columns for me automatically but somethings wrong. I have to do this a few times in my program and I don't really want to do it manually.</p>
  
  <p>So thats the code that I used before</p>
  
  <pre><code>    DELIMITER $$
  DROP PROCEDURE IF EXISTS RepeatLoopProc$$
  CREATE PROCEDURE RepeatLoopProc()
    BEGIN
            DECLARE x  INT;
            DECLARE str  VARCHAR(255);
            Declare @sql nvarchar(4000);
            SET x = 0;
  
            REPEAT
                        SET str =  '';
                        SET  str = CONCAT(str,'ossz_levon_het_',x);
                        SET  x = x + 1;
                        set @sql='ALTER TABLE telephelyi_teszt ADD '+ str +'DOUBLE NULL';
  
                        execute @sql;
            UNTIL x  &gt; 50
            END REPEAT;
  
    END$$
  DELIMITER ;
  </code></pre>
  
  <p>I've got a syntax error near the <code>Declare @sql nvarchar(4000);</code> line any ideas?</p>