项目作者: kgeorge314

项目描述 :
A SQL Server (tSQL) based cron implementation using stored-procedures
高级语言: PLpgSQL
项目地址: git://github.com/kgeorge314/tSQLcron.git
创建时间: 2020-04-19T20:15:14Z
项目社区:https://github.com/kgeorge314/tSQLcron

开源协议:GNU Lesser General Public License v3.0

下载


GitHub Releases

tSQLcron

Branch Build Status
master master-tsql-and-tSQLt
latest-release Create - Test - Release

A tSQL based cron utility.

Quick Start

Install

Install tSQLcron using Install_tsqlCron.sql, the latest version is available in the release page.

Example Usage:

  1. DECLARE @out_is_cron_true BIT ;
  2. EXEC tSQLcron.usp_is_date_in_cron_period
  3. @cron_expression = N'* 0/15 * * * *' -- nvarchar(100)
  4. , @validate_date = '2020-01-01 13:15:00' -- datetime
  5. , @out_is_cron_true = @out_is_cron_true OUTPUT -- bit
  6. IF (@out_is_cron_true = 1 )
  7. BEGIN
  8. PRINT 'DO SOMETHING';
  9. END

CRON Expression

Format: {second} {minute} {hour} {day} {month} {day-of-week*}

(*) day of week depends on SQL Server configuration, use the below code snippet to identify the value of Monday SELECT DATEPART(WEEKDAY,'2020-04-13') AS Monday_The_13th_Of_April_2020

Example CRON Expressions:

Description CRON Expression
always/any-time N'* * * * * *'
every 15th minute N'* */15 * * * *'
everyday at a 13:10 N'* 10 13 * * *'
everyday at the 10th minute between 13H-23H range N'* 10 13-23 * * *'
on the 27th of June at any-time N'* * * 27 6 *'
on the 27th of June at 13:10 N'* 10 13 27 6 *'
on the 27th of June at 13:10:30 N'30 10 13 27 6 *'
every monday at 13:10 N'* 10 13 * * 2'
every monday,wed,thu at 13:10 N'* 10 13 * * 2,4,5'
weekdays (mon-fri) at 13:10 N'* 10 13 * * 2-6'
weekdays alternate (mon-fri) at 13:10 N'* 10 13 * * 2-6/2'
midnight on weekends N'* 10 13 * * 2-6/2'