Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2005
    Posts
    9

    Unanswered: Start job from the command prompt?

    I have a Microsoft SQL server that is setup, and inside it is a job. Inside the job is a bunch of lines of transact sql statements.

    I would like to be able to start the job from the command prompt. Moreover, I do not want to have to create new files or modify anything that is existing. I just want to be able to have it set up so that a new user who installs the server and all of the job on their machine fresh, can just punch in the command to run the job.

    I know I can copy the transact sql statements from the job, and run them through the command prompt, but that would be a poor way to do it, because if the statements in the job were ever modified, with this task being automated, the command prompt statements would be out of date.

    So I just need a way to start the existing job from the command prompt. Is this possible? Maybe with OSQL?

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Looks like you will create a batch file with the osql command running sp_start_job. Permissions may be a tad tricky, especially if the user is not the owner of the job.

  3. #3
    Join Date
    Jul 2005
    Posts
    9
    With the install of the server, those system stored procedures are not recognized... "sp_start_job" or "sp_add_jobserver" or "sp_add_jobstep", etc. And I don't want to get into server configuration...

    I'm just calling it like: EXEC sp_start_job @job_name = 'myJobName'

    Just looking for something that will start the existing job from the command prompt without having to first reconfigure anything or install anything new.
    Last edited by FastbackJon; 02-23-06 at 17:22.

  4. #4
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Try calling it as msdb..sp_start_job

  5. #5
    Join Date
    Jul 2005
    Posts
    9
    Awesome, just had to use msdb.dbo.sp_start_job.

    Thanks MCrowley!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •