|
Home > Archive > MS SQL Server > November 2006 > Increment thru dates
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Increment thru dates
|
|
|
| Hi all,
I have a clearly simple question. I just need to iterate thru dates
that are passed as parameters - From date and end date. I need to
execute the following code that currently loops. I am not exactly sure
where I need to put the date loop. Any help pls.
The parameters are here -
@From date datetime
@end date datetime
open store_t
fetch next from store_t into @store_no
--Loop through each Store
while @@fetch_status = 0
begin
print @store_no
exec dbo.Export @store_no,@order_dat
e
exec dbo.Prod_Export @store_no,@order_dat
e
fetch next from store_t into @store_no
end
close st
deallocate st
| |
| Edgardo Valdez, MCTS, MCITP, MCSD, MCDBA 2006-11-16, 7:12 pm |
| If I understand correctly, you can populate a table variable with the dates:
@dates(one per day) starting from the @from_date and ending on the @end_date.
Then loop through the @dates table variable and execute the code you posted
inside of it.
"juya" wrote:
> Hi all,
>
> I have a clearly simple question. I just need to iterate thru dates
> that are passed as parameters - From date and end date. I need to
> execute the following code that currently loops. I am not exactly sure
> where I need to put the date loop. Any help pls.
>
> The parameters are here -
>
> @From date datetime
> @end date datetime
>
> open store_t
> fetch next from store_t into @store_no
> --Loop through each Store
> while @@fetch_status = 0
> begin
> print @store_no
> exec dbo.Export @store_no,@order_dat
e
> exec dbo.Prod_Export @store_no,@order_dat
e
> fetch next from store_t into @store_no
> end
> close st
> deallocate st
>
>
|
|
|
|
|