如题,不要使用Agent,好像waitfor Time 'time'可以,但是可以的话这个语句块该写在什么地方?

解决方案 »

  1.   

    不用job的話,那就用程序來實現定時執行.windows的排程作業應該是不可以執行存儲過程的.
      

  2.   

    1.在程序中用timer定时器来完成.
    2.到某个你规定时候通知某个人去手工完成.
      

  3.   

     System.Timers.Timer t = new System.Timers.Timer();
    you can use t for timing call some method
      

  4.   

    of course ,you can use Windows Service, create a service in your OS,then let it do the task automaticly
      

  5.   

    用功能為什麼不用,反而選一些不太方便的來實現。。也可用windows的維護計劃調用SQL腳本文件
      

  6.   

    Sai~ 11:53:30
        System.Timers.Timer myTimer = new System.Timers.Timer();
                myTimer.Enabled = true;//enable
                myTimer.Interval = 100;//time
                myTimer.Elapsed += new System.Timers.ElapsedEventHandler(myTimer_Elapsed);//delegate
            }        void myTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs t)
            {
             Console.WriteLine("HAha");
            }
      

  7.   

    对于Agent的机制我不很了解,老担心会带来服务器安全问题
      

  8.   

    用windows 维护计划方法,批处理命令如下:
    sqlcmd -Q "EXEC testDB..pro_test"  -S127.0.0.1 -Usa -P123456
      

  9.   

    请问楼上指的是windows计划任务吗
      

  10.   

    搂主是想要这样做吧?
    5秒触发 print @flag 的值create table  runFlag(flag char(1))
    insert runFlag
    selecT 'Y'
    declare @flag char(1)
    selecT @flag=flag from runFlag
    while (@flag='Y')
    begin
       waitfor DELAY  '00:00:05'
       selecT @flag=flag from runFlag
       print @flag
    end
    ---- 终止运行
    update runFlag set flag='N'
      

  11.   

    判断时间就可以了declare @flag char(1)
    declare @Time char(10)
    selecT @flag=flag from runFlag
    while (@flag='Y')
    begin
       selecT @flag=flag from runFlag
       set @Time=datePart(hh,getdate())+':'+datePart(mi,getdate())
       if (@Time='13:00')
           begin
               print 'run'
           end 
        waitfor DELAY  '00:00:01'
    end
      

  12.   

    firewold有QQ吗?可否QQ上交流一下
      

  13.   

    firewold有QQ吗?可否QQ上交流一下,我的是364612936
      

  14.   

    的确要放到存储过程中,并一直运行,如果你要让它停可以用表中的Flag字段控制
    但你要启动他就只能手动做。工作时间上不了QQ,公司太没人性了!
      

  15.   

    read the fxxking manual
    or
    ask the fxxking googleif Windows
    1. 在数据库中创建存储过程 sp_do_sth
    2. 在操作系统中创建一个 execsp.sql 文件,内容如 "exec sp_do_sth \n go"
    3. 在操作系统中创建一个 task.bat 文件,内容如 "isql -Usa -Ppassword -SServerName -ic:\execsp.sql"
    4. 开始,计划任务,设定一个任务执行这个 task.bat 就行了if Linux/Unix
    [code=BatchFile]root>crontab -l0 1 * * * /opt/jobs/nightly.sh
    0 */1 * * * /opt/jobs/every_1_hr.sh
    */20 * * * * /opt/jobs/every_20_min.sh[/code]
    f1 f2 f3 f4 f5 programf1 是表示分钟,
    f2 表示小时,
    f3 表示一个月份中的第几日,
    f4 表示月份,
    f5 表示一个星期中的第几天。
    program 表示要执行的程序。当 f1 为 * 时表示每分钟都要执行 program,f2 为 * 时表示每小时都要执行程序,其馀类推
    当 f1 为 a-b 时表示从第 a 分钟到第 b 分钟这段时间内要执行,f2 为 a-b 时表示从第 a 到第 b 小时都要执行,其馀类推
    当 f1 为 */n 时表示每 n 分钟个时间间隔执行一次,f2 为 */n 表示每 n 小时个时间间隔执行一次,其馀类推
    当 f1 为 a, b, c,... 时表示第 a, b, c,... 分钟要执行,f2 为 a, b, c,... 时表示第 a, b, c...个小时要执行,其馀类推
    使用者也可以将所有的设定先存放在档案 file 中,用 crontab file 的方式来设定时程表。
      

  16.   

    呵呵,MS设计了Agent,就是为了解决这类问题的,为何不用呢