SQL Job Agent
-
Monday, May 07, 2012 7:23 AM
Hi All,
Using SMO in the .net whether
1. i can create the sql job from my web application.
2. Suppose i can able to create sql job means then which table will insert the job details.
3. Already created SQl jobs details can be able to view in the Web application.
4. SQl job History details can be view able in web application.
Thanks
prathap
- Edited by Prathap Kumar Monday, May 07, 2012 7:24 AM
All Replies
-
Monday, May 07, 2012 12:16 PM
1.I can create the sql job from my web application.
Yes, you can create using SMO. Use below code snippet.Server svr = new Server(instance); JobServer agent = svr.JobServer; if (agent.Jobs.Contains("New Smo Job")) { agent.Jobs["New Smo Job"].Drop(); } Job j = new Job(agent, "New Smo Job"); JobStep js = new JobStep(j, "Step 1"); js.SubSystem = AgentSubSystem.TransactSql; js.Command = "select 1"; j.Create();2.Suppose i can able to create sql job means then which table will insert the job details
Probabaly this information should go to msdb..sysjobs Table. You can see thisSELECT * FROM msdb..sysjobs
3.Already created SQl jobs details can be able to view in the Web application.
You can use the JobServer.EnumJobs method which returns you a Data table containing list of jobs.
4.SQl job History details can be view able in web application.
You can call the EnumHistory method of the Job class and find out the history and bind it to your asp.net control. Or you can execute sp_help_jobhistory using a SQLcommand object.Lingaraj Mishra
- Marked As Answer by Prathap Kumar Monday, May 07, 2012 12:41 PM

