sql2005

在SQL2005中我要对表中的工龄进行更新,条件是每年的1月1号早上六点自动加1,在作业里怎么设置呀,里面的执行周期没有每年的,只有天,周,月?求解????

OK ! 那我就说说!
主要内容: java 里面的 timer 定时器!
实现如下:
[code="java"]
public class TaskManager implements ServletContextListener { //implements ServletContextListener
/**

  • 定时器
    */
    private Timer timer;

    public static final long MILLIS_IN_HOUR = 3600*1000;
    public static final long MILLIS_IN_DAY = MILLIS_IN_HOUR *24;

    public TaskManager() {
    }
    /**

  • 在Web应用启动时初始化任务
    *

  • @param sce ServletContextEvent
    /
    public void contextInitialized(ServletContextEvent sce ) {
    //定义定时器
    timer = new Timer(true);
    Date now = new Date();
    int year = now.getYear();
    // 每年的 1月 1号 早上 6点执行此任务
    timer.schedule("你要执行的操作",new Date(year, 1, 1, 6, 0, 0),MILLIS_IN_DAY);

    }
    /
    *

  • 在Web应用结束时停止任务

  • @param sce ServletContextEvent
    */
    public void contextDestroyed(ServletContextEvent sce) {
    timer.cancel(); // 定时器销毁
    }

}

[/code]

自己写个触发器 或者 执行下 sql 语句能行? 作业? 不熟。。 :wink:

在程序里面写个 定时器 也行啊! timer
到指定 的时间 自动执行这个业务!