I need to transfer some data from SQL Server to MySQL, once a month. I have already done this transfer stuff, but I don't know (and I have not found out on the internet) how to set a timer that executes this transfer a specific day every month. I don't want just to set a timer interval in milliseconds because the number of days vary from one month to another.
Any help is appreciated...
You could use the Windows Task Scheduler for this kind of work. Look here for command line options of Schtasks
(there's tons of them)
Example 1:
To schedule a task that runs on the first day of every month
The following command schedules the MyApp program to run on the first
day of every month. Because a value of 1 is the default for both the
/mo (modifier) parameter and the /d (day) parameter, these parameters
are omitted from the command.
schtasks /create /tn "My App" /tr myapp.exe /sc monthly
Example 2:
To schedule a task for the 15th day
The following command schedules the MyApp program to run on 15th of
every month at 3:00 P.M. (15:00). It uses the /d parameter to specify
the date. It also uses the /st parameter to specify the start time.
schtasks /create /tn "My App" /tr myapp.exe /sc monthly /d 15 /st 15:00
This sounds like something you should set-up as a scheduled task or a SQL server job rather than having a process run for a month via a timer?
Links:
- SQL Server job in 2008
- Schedule windows task
I guess you could also setup a task as a windows service and check the last time you did the update via a setting in the database, but that seems like overkill. From the sound of it you already have a C# app setup that does the job, so I would just make a scheduled windows task.