title: SQL INSERT Using WHILE LOOP and SELECT
body: <p>Need to add a bunch of repetitive records to the database and don't want to do all of it by hand.</p>
  
  <p>Need to add the intial records by hand but then want to create a query I can run to essentially template rest of the records and then just change the one different field by hand.</p>
  
  <p>Problem is, I don't know exactly what the initial records are until I enter them.</p>
  
  <p>For example</p>
  
  <pre><code> FieldOne | FieldTwo   | FieldThree
  ----------+------------+--------------
   Text One | Text Two A | int Three A
   Text One | Text Two B | int Three A
   Text One | Text Two C | int Three A
   ...
  </code></pre>
  
  <p>This all has to be done by hand. I then need to create:</p>
  
  <pre><code> FieldOne | FieldTwo   | FieldThree
  ----------+------------+--------------
   Text One | Text Two A | int Three B
   Text One | Text Two B | int Three B
   Text One | Text Two C | int Three B
   ...
  </code></pre>
  
  <p>... repeat for all the different values in Field Two.</p>
  
  <p>Hope that makes sense?</p>
  
  <p>Essentially what I want to do is:</p>
  
  <pre><code>WHILE (SELECT ALL DISTINCT VALUES FIELDTWO)
  BEGIN
  INSERT INTO TABLE VALUES ('Same all the time', Value From the FieldTwo Select, 'Same all the time')
  END
  </code></pre>
  
  <p>Can this be done in SQL Server and can you give me the exact T-SQL statement to do it?</p>