现在的位置: 首页 > 综合 > 正文

如何使用T-SQL来给系统增加计划任务,

2013年04月06日 ⁄ 综合 ⁄ 共 382字 ⁄ 字号 评论关闭

 

declare @RunTime char(5)
declare @String char(100)
set @RunTime=left(convert(char(5),getdate(),8),2+ ':' + convert(char(2),convert(int,right(convert(char(5),getdate(),8),2) )+1,2)
set @String='at '+ @RunTime + ' /interactive ' + ' C:windowssystem32 otepad.exe'
exec ('master..xp_cmdshell "'+@String +'"')

上面的脚本是在当前时间后的1分钟增加一个任务。如果直接执行
xp_cmdshell @String 会报错,最终还是在MSDN的Community中找到了解决的办法。

抱歉!评论已关闭.