Terrace
asked on
SQL 2000 - for Loop to insert a range of dates and values at once
What is the best way to do this?
Have a table tblMax with DateFund and Maxvalue fields.
Need to fill that table with range of dates from 02/12/2009 - 01/01/2010
DateFund MaxValue
02/12/2009 0
02/13/2009 0
etc
I guess it would be some For Loop in SQL Analizer or Stored Procedure.
Can anyone write me a quick simple code for it?
Thanks
Have a table tblMax with DateFund and Maxvalue fields.
Need to fill that table with range of dates from 02/12/2009 - 01/01/2010
DateFund MaxValue
02/12/2009 0
02/13/2009 0
etc
I guess it would be some For Loop in SQL Analizer or Stored Procedure.
Can anyone write me a quick simple code for it?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
set @tmp = '02/12/2009'
while @tmp <= '01/01/2010'
begin
insert into yourTable(DateFund, MaxValue)
values (@tmp, 0)
set @tmp = dateadd(day, @tmp, 1)
end