|
sql
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Increment thru dates
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_date exec dbo.Prod_Export @store_no,@order_date fetch next from store_t into @store_no end close st deallocate st 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. Show quoteHide quote "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_date > exec dbo.Prod_Export @store_no,@order_date > fetch next from store_t into @store_no > end > close st > deallocate st > >
Other interesting topics
Need help troubleshooting a memory paging issue
List of running stored procedures limited permissions on test server for developers Spid checker query help Low Disk Space Delete records in a table with 15 dependencies how to remove the sql server registry mess? CHECKING the TRANSACTION LOG Remote Production Database Issue Installed SQL2000 SP4 successfully but still shows RTM as installe |
|||||||||||||||||||||||