How to run a Job from a Stored Procedure in another server?

纵饮孤独 提交于 2019-12-07 18:04:46

问题


Is it possible to run a Job from a stored procedure located in a different server? If so, how?


回答1:


So why not consider using

exec LINKEDSERVERNAME.msdb.dbo.sp_start_job 'Job Name'

?

(didn't test it though, maybe some-unseen-answer was the same, but erased as incorrect and not working)

There must be enough privileges for linked-server-login to run the job, of course - at least it has to be job's owner.




回答2:


Yep, you can use the evil that is osql:

osql -S "Remote Server" -E -Q"exec msdb.dbo.sp_start_job 'Job Name'"

(Where -E denotes using a trusted connection, you can also specify credentials using alternative osql syntax)



来源:https://stackoverflow.com/questions/5573227/how-to-run-a-job-from-a-stored-procedure-in-another-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!