title: Inserting a multiple records in a table with while loop
body: <p>I want to insert couple of hundred rows into a table that points to pk in other table. I have been trying to use while loops for inserting multiple records in the table. I am actually setting up my test data.</p>
  
  <p>This is what I am doing :</p>
  
  <pre><code>declare @count int;
  set @count = 4018;
  
  while @count &lt;= 5040 
  begin
      INSERT INTO [MY_TABLE]
                 ([pk_from_other_table]
                 ,[..]
                 ,[...]
                 ,[..]
                 ,[..]
                 ,[...]
                 ,[...]
                 ,[..])
          select
                 (pk_from_other_table,
                 ,[..]
                 ,[...]
                 ,[..]
                 ,[..]
                 ,[...]
                 ,[...]
                 ,[..])
      @count = @count + 1;
  end
  </code></pre>
  
  <p>but this does not seems to work ! can anyone help please... all I want to do is insert number of records = number of records that exist in primary table.</p>
  
  <p>? any idea on how can I achieve this ?</p>
  
  <p>I either get incorrect sytax near count </p>
  
  <p>or </p>
  
  <p>Msg 102, Level 15, State 1, Line 17
  Incorrect syntax near ','.</p>