Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Disable a job step?

Author  Topic 

ratinakage
Starting Member

16 Posts

Posted - 2007-10-19 : 07:17:26
Hey guys,

I know you can disable a SQL job. What I want to know is, if anyone can think of a clever way to disable a job step?

Basically, I want to create a big SQL job with all the steps disabled. Then as the users of my app turn certain things on, the job steps should become activated (or enabled).

My first thought was to do something like this.

1. dummy step. Next step = 3
2. real step a Next step = 3
3. dummy step Next step = 5
4. real step b Next step = 5
5. dummy step Next step = 7
6. real step c Next step = 7
....

Where you basically have a job so that none of the steps are enabled and they are all skipped over. Then as things need to be enabled, you just change the next step to next step - 1 (or something like that)

Its a bit messy. Can you think of anything else?

Thanks,

nr
SQLTeam MVY

12543 Posts

Posted - 2007-10-19 : 08:17:03
Think you probably don't want to use the scheduler to do this.
Try holding the steps in a table which you can then flag as enabled or disabled and use a stored proc to action them.
You can then schedule that SP.

Could have the above SP but it runs the steps individually in the job - all steps ae set to quit on success. The SP checks for completion and success. A variation is that each step runs step 1 afterwards which starts another job which calls the controll sp to start the next step (the extra job is because you can't run the control SP directly from the job as the jobs already running)

You could also have a stored proc set the step precedence before running the job - maybe have another job for the scheduling and this sp starts the job when it has set the steps.

Each of your dummy steps above looks at a table to see if it's step is enabled. If not it errors. Set it to run the next step on success, the one after on error.

Sounds a bit like you might want to create a scheduler - something like
http://www.nigelrivett.net/Products/Scheduler.html

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2007-10-19 : 08:29:45
Duplicate of http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=91273
Go to Top of Page
   

- Advertisement -