Sql Agent Job Portability between dev, qa and prod

  • I'm trying to build a SQL Agent job on dev machine that will run on dev, qa and prod without any changes. Once the job is built on dev, I would like to generate a script for the job on dev and run the generated script unchanged on sq and prod. And of course have the unchanged job work on qa and prod.

    I'm trying to figure out how to set the job step output file assignment, found under the advanced tab when editing a job step, so it will work regardless of machine it runs on. Note method needs to support different physical drive setup on each sql server machine.

    Here are the three different physical files where the output should go by machine for a single job step:

    - output file on dev machine is c:\output\joba_step1.txt

    - output file on qa machine is g:\output\joba_step1.txt

    - output file on prod machine is f:\output\joba_step1.txt

    Each of these file can also be referenced by UNC as well:

    - UNC for dev is \\dev\sqldata\output\joba_step1.txt

    - UNC for QA is \\qa\sqldata\output\joba_step1.txt

    - UNC for PROD is

    \\PROD\sqldata\output\joba_step1.txt

    So what might i put in the output file box to identify the name of the file. I tried \\%COMPUTERNAME%\sqldata\output\joba_step1.txt but this did not work.

    Any other suggestions.

    Gregory A. Larsen, DBA

    Contributor to 'The Best of SQLServerCentral.com 2002' book. Get a copy here: http://www.sqlservercentral.com/bestof/

    Need SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples

    Gregory A. Larsen, MVP

  • can you use conditional logic to determine which machine your on?

    if computername = 'dev'

    put it here

    else if computername = 'qa'

    put it here

    else

    put it here

    you know what? it just occurred to me that you are putting this in the Output file box in the Advanced tab... guess conditional logic won't work there. gonna leave the message though and add the following qualifier:

    you could go to great lengths to include your output in the step logic and then use the above suggestion.

    Edited by - hoo-t on 12/26/2003 06:55:23 AM

  • Don't think you can, unless you have the same drive letter in all your servers.

    I think you will have to, at least, replace the server name with the @@servername function in your job script.

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

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