title: ForEach Loop in SQL Server
body: <p>I have a list of values that, i.e. </p>
  
  <pre><code>in ('1xxx','12xx','21xx','98xx','00xx')
  </code></pre>
  
  <p>I want to use for an insert script. How can a write a for loop in SQL Server using each value within the loop? I'm think something like.</p>
  
  <pre><code>For value in ('1xxx','12xx','21xx','98xx','00xx')
    select value
  endloop;
  </code></pre>
  
  <p><strong>Im trying to simply this</strong></p>
  
  <pre><code>    INSERT INTO [dbo].[TimeCard]
      VALUES
              ('test'+Right(NewId(),12),'6121126800','5102289289',CONVERT(DATE,'01-01-2013'),CONVERT(DATE,'01-01-2013'),20,CURRENT_TIMESTAMP,NULL )
      GO
  
      INSERT INTO [dbo].[TimeCard]
      VALUES
              ('test'+Right(NewId(),12),'6121126800','5102289289',CONVERT(DATE,'01-08-2013'),CONVERT(DATE,'01-08-2013'),20,CURRENT_TIMESTAMP,NULL)
      GO
  
  
      INSERT INTO [dbo].[TimeCard]
      VALUES
              ('test'+Right(NewId(),12),'6121126800','5102289289',CONVERT(DATE,'01-15-2013'),CONVERT(DATE,'01-15-2013'),20,CURRENT_TIMESTAMP,NULL )
      GO
  ....
  </code></pre>
  
  <p>I have to insert these records for several testing scenarios.</p>