如何创建sql预定代理作业? [英] how to create sql scheduled agent job ?

查看:74
本文介绍了如何创建sql预定代理作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个每天下午12点运行的sql代理作业,例如

i设置此代码蚂蚁它确定创建的工作

但是我如何设置时间表??

i want to create a sql agent job run daily at 12 pm for example
i set this code ant its ok the job created
but how can i set the schedule ??

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);

ServerConnection svconn = new ServerConnection(con);
svconn.Connect();

Server server = new Server(svconn);


JobServer jobServer = server.JobServer;
Job job = null;
JobStep step = null;


// Create Job 
job = new Job(jobServer, job_Name);

job.Create();
job.ApplyToTargetServer("(local)");


// Create  db step 
if (createDB_command != "")
{
   
    step = new JobStep(job, "Creationdb_Step");
    step.Command = createDB_command;
    step.SubSystem = AgentSubSystem.TransactSql;
    step.OnSuccessAction = StepCompletionAction.GoToNextStep;
    step.Create();
}

推荐答案

请参阅以下链接:

MSDN:使用C#和SMO创建SQL代理作业 [ ^ ]

使用C#为SSIS包创建SQL作业 [ ^ ] < br $> b $ b



- Amy
Refer the links below:
MSDN : Create SQL Agent job using C# and SMO[^]
Create SQL Job for SSIS Package by using C#[^]


--Amy


这篇关于如何创建sql预定代理作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆