• sqlserver 延期执行sql


    以下示例在晚上 10:20 (22:20) 执行存储过程 sp_update_jobUSE msdb;
    EXECUTE sp_add_job @job_name='TestJob';
    BEGIN     WAITFOR TIME '22:20';    
    EXECUTE sp_update_job @job_name='TestJob',  @new_name='UpdatedJob';
    END;
    GO

    以下示例在两小时的延迟后执行存储过程。注意:Delay最多不超过24小时

    BEGIN    
    WAITFOR DELAY '02:00';    
    EXECUTE sp_helpdb;
    END;
    GO

    USE AdventureWorks2008R2; GOIFOBJECT_ID('dbo.TimeDelay_hh_mm_ss','P') ISNOTNULL     DROPPROCEDURE dbo.TimeDelay_hh_mm_ss; GOCREATEPROCEDURE dbo.TimeDelay_hh_mm_ss     (     @DelayLengthchar(8)='00:00:00'     ) ASDECLARE@ReturnInfovarchar(255) IFISDATE('2000-01-01 '+@DelayLength+'.000') =0     BEGIN         SELECT@ReturnInfo='Invalid time '+@DelayLength         +',hh:mm:ss, submitted.';         -- This PRINT statement is for testing, not use in production.        PRINT@ReturnInfo         RETURN(1)     ENDBEGIN     WAITFOR DELAY @DelayLength     SELECT@ReturnInfo='A total time of '+@DelayLength+',         hh:mm:ss, has elapsed! Your time is up.'     -- This PRINT statement is for testing, not use in production.    PRINT@ReturnInfo; END; GO/* This statement executes the dbo.TimeDelay_hh_mm_ss procedure. */EXEC TimeDelay_hh_mm_ss '00:00:10'; GO

  • 相关阅读:
    QAction使用
    QT学后感
    设置背景图片
    获取句柄的方法总结(尤其是对于dll而言)
    unixbench小试
    Java命令行之jar命令
    Java应用程序安装包制作工具简介
    Eclipse使用ant编译时的乱码问题
    Jboss4中使用配置发送邮件
    Exe4j注册码
  • 原文地址:https://www.cnblogs.com/i80386/p/2268939.html
Copyright © 2020-2023  润新知