View Single Post
  #10 (permalink)  
Old 12-01-09, 12:12
chrismilleruk chrismilleruk is offline
Registered User
 
Join Date: Dec 2009
Posts: 1
Update

I thought I'd just update this thread with the latest info as came up number 1 in Google and didn't quite answer the question for me.

You can run a SQL server agent job from the command line with the following:
Code:
osql -E -d MSDB -Q "sp_start_job 'MySQLJob'"
-E means use use Integrated (Windows) security. If you need to use a SQL username and password, you can do this instead:
Code:
osql -U user1 -P password -d MSDB -Q "sp_start_job 'MySQLJob'"
Either of these statements can be placed inside a batch file for convenience but it's important to note that if you use a % character in your command line then it needs to be escaped to %% when used from inside the batch file.

The following links may also be useful:
sp_start_job docs (note the required permissions)
osql Utility
Reply With Quote