Question

I am using Sql server 2005 and using C#/Asp.Net 4.0 for UI. I want to trigger the sql job from an user action in a webpage. I need to keep checking job's status while its running. There are several old threads on this issue which gets the status of the jobs (How to monitor SQL Server Agent Job info in C#) but i need my program should be able to Run,Stop,Enable,Disable the jobs

I need the below functionality in my UI.

  1. Check the status of a sql job

  2. Run the specified job

  3. Stop the job

  4. Disable/Enable the job

Was it helpful?

Solution

You can use the following system stored procedures:

sp_start_job - start an Agent job
sp_stop_job - stop an Agent job
sp_update_job - enable/disable an Agent job

Update: If you really want to use SMO instead, best place to check out is this MSDN reference. The Job class allows you to do all this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top