I need to do something like this in sql:
declare @StartDate varchar(10)
declare @EndDate varchar(10)
Declare @date varchar = @StartDate
while (@date <= @EndDate)
-- some statements
set @date += 1 -- basically increment by 1 day
How can I do the above correctly in SQL? Basically, my startdate and enddate are strings and not datetimes because my business logic is referencing string column in another table with a date as the name of the column-But I need to loop through a bunch of columns, each column having the name of the next day’s date.
If the date is 11/07/2009, the name of the column would be ’11/7/2009′ (without the 0 in the 7), so I have to watch out for that too.
Any help is appreciated!