SQL Jobs

  • The answer should be yes.

    Can the author come up with an example where the answer is actually "No"? Also, it would be great to clarify whether the output file is finally there in the required location or not!

    2 questions, 1 answer - reminds me of algebra and how it's impossible to solve for two unknowns with just one equation!

    Thanks & Regards,
    Nakul Vachhrajani.
    http://nakulvachhrajani.com

    Follow me on
    Twitter: @sqltwins

  • Nakul Vachhrajani (3/27/2015)


    ...reminds me of algebra and how it's impossible to solve for two unknowns with just one equation!

    xy=1 where x and y are positive integers

    x=1, y=1

    😀

  • Stewart "Arturius" Campbell (3/26/2015)


    If there is a Syntax error in the script to create a job, the job will not be created.

    however, if the syntax error is in the command being executed by the job step, the output file will be created, unless the SQL agent does not have access to the required destination.

    Even that's not quite accurate: a syntax error may be detected while executing a part of the script that adds a job step (say step 37 of 37, so that the job is created but with only 36 steps of the required steps) or the syntax error is in the part of the script that adds the last of many schedules so the job is created but runs only according to the schedules created before that point. More generally, syntax errors can be pretty well anywhere in the script as long as syntax errors are separated by batch boundaries (script lines saying GO) from the sp_add_job call and from at least one sp_attach_schedule call (for either a pre-existing schedule or a schedule created by a similarly protected (by separation from the errors) sp_add_schedule call) and from at least one sp_add_jobstep call without preventing the job from being created and running (but the job probably won't do what it was intended to do :-P).

    Someone has already pointed out that a syntax error in the t-SQL or Active Script or CMDEXEC or MDX or DMX or PowerShell or XMLA (or of course whatever the rest of the options are called) text of the @command parameter to an sp_add_jobstep call does not prevent the job from being created, and it can't be argued that that doesnt count as an error in the job - if it isn't why does it cause a run-time failure in the job - and the question specifies an error in the job. not an error in the job script.

    This is a pretty poor question: it's phrased so that it is utterly unclear. The answer is completely wrong. The explanation introduces a reference to "the jobstep" as if the job must have only one, which was not stated as part of the question. The assumption that jobsteps with syntax errors in them won't run, which the explanation clearly assumes, is pure balderdash with respect of most of the languages that jobstep commands can be written in (or at least in respect of most of the ones that I can write them in).

    But at least it may make people think about how many ways a syntax error in the job creation script can leave you with a job that runs but does the wrong thing so that they try to write job creation scripts in such a way that such errors make them fail to create the jobs (of course nothing can ensure that syntax errors with @command contents prevent the job from being created, so that will rely on syntax checking @command strings using the approriate subsystem before using them in sp_add_jobstep or sp_update_jobstep calls). In fact it may make people think harder than is it had been a ice tidy question with correct answer and explanation.

    Tom

  • sestell1 (3/26/2015)


    I think whether the file gets created depends on if the syntax error causes the package to fail validation or not. I think the second question also depends on how far the package makes it, so I hedged my bets as to which question was being asked and went with 'sometimes'.

    If the syntax error is inside the jobstep that specifies the output file, as opposed to in adding it, the step will run and the file will be written (so the answer would be "yes" if this is the only case) but if it's in some other jobstep whose error leads to the only jobstep which specifies the output file not being executed then maybe nothing will be written to the file/or the file won't be created or modified, and if the second situation is allowed the answer is "sometimes". But the output file is to hold the output of the job (according to the question), not just the output of one jobstep, so presumably every jobstep should specify it so the correct answer is actually YES, because the second case isn't allowed.

    The case where the syntax error is in the command creating a jobstep isbn't a valid one, because that's not a syntax error in the job, it's a syntax error in the job creation script.

    But I had looked quickly and gone with "sometimes" before I made the above reasoning - careless of me, I should have gone with "yes" and lost the point by getting the wrong right answer instead of for getting the wrong wrong answer. At least we both managed to avoid getting the point for picking the right wrong answer :w00t:

    Tom

  • It all depends WHERE the syntax error is - whether the job will be created, how the job will run when created - the correct answer is therefore sometimes

  • Thanks for the question.

  • TomThomson (3/27/2015)[

    But I had looked quickly and gone with "sometimes" before I made the above reasoning - careless of me, I should have gone with "yes" and lost the point by getting the wrong right answer instead of for getting the wrong wrong answer. At least we both managed to avoid getting the point for picking the right wrong answer :w00t:

    +1

  • I lost a point :(... the answer should be "Yes"!

Viewing 8 posts - 31 through 37 (of 37 total)

You must be logged in to reply to this topic. Login to reply