Edit at bottom coming up. Jump to the MSFT section below.
(this top chunk was just because the question somehow had the mysql tag in it initially, my apologies to you MSFT guys.)
MYSQL
Consider using mysql's Create Event strategy that can take away from needing to do cron jobs.
DELIMITER $$
CREATE EVENT annualThingEvent
ON SCHEDULE EVERY '1' YEAR
STARTS '2016-01-01 00:00:00'
DO
BEGIN
-- perform some annual thing, as complicated as you want
END$$
DELIMITER ;
From the Manual page on CREATE EVENT,
interval:
quantity {YEAR | QUARTER | MONTH | DAY | HOUR | MINUTE |
WEEK | SECOND | YEAR_MONTH | DAY_HOUR | DAY_MINUTE |
DAY_SECOND | HOUR_MINUTE | HOUR_SECOND | MINUTE_SECOND
Properly setting up events to even happen and monitoring them is important.
show variables where variable_name='event_scheduler';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| event_scheduler | OFF |
+-----------------+-------+
ooops, the event scheduler is not turned on.
Well I can wait all day long, events aren't even turned on
SET GLOBAL event_scheduler = ON; -- turn her on
show variables where variable_name='event_scheduler';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| event_scheduler | ON |
+-----------------+-------+
List all events by schema name:
show events from so_gibberish;
or
show events\G; -- <--------- I like this one from mysql> prompt
show events; -- <--------- from workbench / sqlyog
*************************** 1. row ***************************
Db: so_gibberish
Name: set_trips_finished
Definer: GuySmiley@localhost
Time zone: SYSTEM
Type: RECURRING
Execute at: NULL
Interval value: 1
Interval field: MINUTE
Starts: 2015-08-23 00:00:00
Ends: NULL
Status: ENABLED
Originator: 1
character_set_client: utf8
collation_connection: utf8_general_ci
Database Collation: utf8_general_ci
MSFT
Not that I know anything about it, but I include this because in going to delete the whole Answer, the OP asked. So keep that in mind. Lifted from here.
Overview
Scheduling is a very useful feature of every database management software. In the MS SQL Server the SQL Server Agent acts as the scheduler and it executes the tasks.
Explanation
SQL Server Agent is the equivalent of the MySQL Event Scheduler. It is part of every edition except MS SQL Express. It can be accessed from SQL Server Management Studio.
However, the MS SQL implementation is very different from the CREATE EVENT statement syntax in MySQL. You have to create jobs, job steps and schedules separately. There are two ways to perform this task, you can either use the GUI or create Transact-SQL statements.
The general steps to create a scheduled job using T-SQL are the following:
- Execute
sp_add_job to create a job.
- Execute
sp_add_jobstep to create each job step.
- Execute
sp_add_schedule to create a schedule. You can define more
schedules, e.g. run at 3am and 11pm.
- Execute
sp_attach_schedule to link the schedule to the job.
- Execute
sp_add_jobserver to set the server for the job.
Also, look at this MSDN article about Implementing Jobs.