Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I run a job from another server using a stored procedure?

Let's say

  • server 1 : db1
  • server 2 : db2
  • username : testssis
  • password : testssispass
  • sqljob found in db2: job1

Here is the part im lost with how can I make this work?

xp_cmdshell + osql command -U: -P: + sp_startjob
share|improve this question

migrated from Apr 25 '13 at 10:14

This question came from our site for professional and enthusiast programmers.

possible the same as this question – shibormot Apr 25 '13 at 4:33
Certainly does seem like a duplicate. to me, Rad's answer seems superior to Timbo's. Using osql and xp_cmdshell seems brittle and may lead to security problems (hardcoded, cleartext passwords). – darin strait Apr 25 '13 at 15:50

With a linked server - much more reliable and secure than xp_cmdshell:

EXEC Server2.msdb.dbo.sp_start_job @job_name = N'Job2';
share|improve this answer

You can have the Sql job in a stored Procedure in server B. Add server B as linked server to Server A, Execute the stored Procedure from server A:

EXEC [RemoteServer].DatabaseName.DatabaseOwner.StoredProcedureName
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.