Start Agent Job on another Server

  • Hi

    Is it possible to start a sql agent job on another server from the command line? e.g.

    1. Backup database on server Prod using osql. On succesfull Completion, start an agent job on Server Dev to restore this database using osql from server Prod.

    Or, is there a better way of doing this?

    Thanks

    Andy

  • If you have a link server entry, you can try something like...

    LinkedServer.Master.dbo.sp_ExecuteSQL N'Exec SyJobExecute_sp ''JobName'', 0'



    Once you understand the BITs, all the pieces come together

  • Thanks Thomas, I couldn't find syjobexecute, but I succesfully used:

    linkedserver.Master.dbo.sp_ExecuteSQL N'EXEC msdb.dbo.sp_start_job @job_name = "Test Job"'

    Andy

  • Yeh, sorry, that's my own build in SP, does some intermediate logging work etc.

    Glad the "jist" of the idea worked for you.



    Once you understand the BITs, all the pieces come together

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

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