script to create a job

  • Is there a way to create a T-SQL script to create a job instead create by myself on enterprise manager?

     

    thanks

     

    Edwin G.

  • You can use following stored procedure.You can refer books online for more information.

    sp_add_job [ @job_name = ] 'job_name'

        [ , [ @enabled = ] enabled ]

        [ , [ @description = ] 'description' ]

        [ , [ @start_step_id = ] step_id ]

        [ , [ @category_name = ] 'category' ]

        [ , [ @category_id = ] category_id ]

        [ , [ @owner_login_name = ] 'login' ]

        [ , [ @notify_level_eventlog = ] eventlog_level ]

        [ , [ @notify_level_email = ] email_level ]

        [ , [ @notify_level_netsend = ] netsend_level ]

        [ , [ @notify_level_page = ] page_level ]

        [ , [ @notify_email_operator_name = ] 'email_name' ]

        [ , [ @notify_netsend_operator_name = ] 'netsend_name' ]

        [ , [ @notify_page_operator_name = ] 'page_name' ]

        [ , [ @delete_level = ] delete_level ]

        [ , [ @job_id = ] job_id OUTPUT ]

     

     

    Thanks,
    SR

  • Start Profiler.

    Start recording.

    Create a new job from EM.

    Stop recording.

    Read the command EM used to create that job.

    Copy commands to QA.

    See BOL for the meaning of the commands and parameters.

    Change whatever you need to change to meet your requirements to automated script (start-stop time, number of steps, etc.)

    Save the script.

    _____________
    Code for TallyGenerator

  • Create the job by hand in Enterprise Manager or Management Studio and after that you have the possibility to right click on it and "Script job as". Use that script for your further needs.

    I'd cry, but I can't stop laughing.

  • This is a great collection of solutions!

Viewing 5 posts - 1 through 4 (of 4 total)

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