Posted By

kidmizere on 12/12/13


Tagged

records loop add dates while


Versions (?)

Add dated records to MSSQL using while loop


 / Published in: SQL
 

This loop adds a bunch of records to your database with a date field pre-populated. Works well for pre-populating a table for filling out daily by a form

  1. declare @imax INT,
  2. @i INT
  3. SET @imax = 400 -- change to max value
  4. SET @i = 1
  5.  
  6. while (@i <= @imax)
  7. Begin
  8. INSERT INTO Workflow_status
  9. (WF_date)VALUES (convert(date, getdate() + @i,101))
  10. SET @i = @i + 1
  11.  
  12. END

Report this snippet  

You need to login to post a comment.