Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Run SQL Server Job from Command Line Expand / Collapse
Author
Message
Posted Wednesday, March 21, 2007 12:16 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, March 7, 2013 6:16 AM
Points: 90, Visits: 350

Good afternoon,

I need to daisy chain a SQL Server job with an AS400 job (have the AS400 job kick off the SQL Server job). I've been told that this can be done but how do I do this? What connectivity do I need and more pressing right now, what is the command line syntax for such a job?

thanks,

Bob

Post #353040
Posted Wednesday, March 21, 2007 1:59 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, October 28, 2014 3:06 PM
Points: 1,143, Visits: 1,003
use either osql or sqlcmd, depending on your version of SQL (2000 uses osql, 2005 is sqlcmd)

you can use that to run sp_startjob

so your command may look like this:
osql -E -SserverName -q"sp_start_job @job_name = 'job_name', @server_name = 'server_name'"
Post #353067
Posted Wednesday, March 21, 2007 3:20 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, March 7, 2013 6:16 AM
Points: 90, Visits: 350

Thanks Adam... I had to tweak it just a bit but it works. One further question... when I run this from a command prompt, after it starts, there is a message that the command "started successfully." Then the next line looks like this...

1>

If I press the enter key it simply adds a >2 below that.

Does this mean the system is waiting on something to get me back to a regular command prompt?

Thanks again,

Bob

Post #353087
Posted Wednesday, March 21, 2007 3:54 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, March 7, 2013 6:16 AM
Points: 90, Visits: 350

Adam, I figured it out... in your example change the small q to a captial Q

Thanks again, Bob

Post #353092
Posted Friday, March 23, 2007 8:24 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, March 7, 2013 6:16 AM
Points: 90, Visits: 350

I got this to work using the sa account but not when I run it with a SQL Server account. I gave rights to the SQL Server account to execute the stored procedure as well as the sp_start_job stored procedure.

Any ideas how I can get a generic SQL Server account to work?

Thanks,

Bob

Post #353524
Posted Tuesday, February 26, 2013 8:54 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, November 27, 2013 7:57 AM
Points: 7, Visits: 10
I am trying to use the same command and I am having trouble getting it to work. I am running this:



RUNRMTCMD CMD('sqlcmd -U user -P password -S server name -Q "msdb.dbo.sp _start_job @job_name = ''FACT852: ProcessRetailSales'', @server_name = '' server''"') RMTLOCNAME('99.99.99.99' *IP) RMTUSER(user) RMTPWD(password)
Post #1424123
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse