Updating SQL job via t-sql

September 24th, 2008 by Mr.M | No Comments »

I was requested to update 7 sql jobs on 8 sql servers this afternoon. The specifics was shown to me via the GUI and I REALLY REALLY REALLY hate doing stuff thru the GUI. To many pointing and clicking and possibility of making a mistake somewhere.

The requirement was that in the existing SQL job, the parameter @options=’debug’ be append to the end of the existing syntax and that the job be outputted to a .txt file on e:joblogs

The following syntax was used to make the requested changes.


exec msdb..sp_update_jobstep @job_name = ‘MasterJobSuckBalls’
, @step_id = 1 — modify step 1
, @command = ‘EXEC someProcedure @param1 = ”YouCanDoIt”, @options=”debug”
, @output_file_name = ‘e:joblogsSuckBalls.txt’
, @on_success_action = 1 — report as successful
GO

Learn to write syntax, it makes everything much easier.

Leave a Reply

You must be logged in to post a comment.