quick sp_add_jobstep @command question

  • Ok, the BOL says that the sp_add_jobstep procedure's @command parameter can use run time tokens (*cough*-variables-*cough*), but how do I set/use them? Anyone have some good tutorials or examples? Would it look like this: @command = 'backup database [A-DBN] ...'? And how do I specify which database is implied (jobs are tied to dbs)?

    TIA

  • Very powerful, very useful, but can seriously mess you up if you don't know they are there. Had an issue once where we called a virtual MACH. We tried to set up replication and it kept dying as it was trying to pass in the machine name.

    Anyway, check out this link for a list of all the tokens.

    http://www.sqldev.net/sqlagent/SQLAgentStepTokens.htm



    Shamless self promotion - read my blog http://sirsql.net

  • Ok, the answer is this line:

    "Alert based tokens only contain a value when the job is invoked via an alert, otherwise the value is always represented as an empty string."

    That means that [A-DBN],[A-SVR],[A-ERR],[A-SEV], and [A-MSG] are pretty much useless.

    Oh well.

Viewing 3 posts - 1 through 2 (of 2 total)

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