﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Connecting / Programming  / Execute a sql job from AS400 command line / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 18 Jun 2013 14:59:03 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Execute a sql job from AS400 command line</title><link>http://www.sqlservercentral.com/Forums/Topic1424127-20-1.aspx</link><description>Thanks.  We got it to work.  We used the RMTCMD command to call a .bat.  The main issue is that we had to use OSQL instead of sqlcmd which is weird because we are on SQL 2005.This is the .batosql -U sqluser -P sqlpassword -S server -Q "EXEC msdb.dbo.sp_start_job N'JOB NAME'" .Also we has to change the user and password for the RMTCMD because it is different than the sql user and password.Thanks for your help.</description><pubDate>Tue, 05 Mar 2013 06:35:26 GMT</pubDate><dc:creator>vconlan</dc:creator></item><item><title>RE: Execute a sql job from AS400 command line</title><link>http://www.sqlservercentral.com/Forums/Topic1424127-20-1.aspx</link><description>[quote][b]thsu (3/4/2013)[/b][hr]I don't remember exactly what I did with that project years ago.But I am sure that no need to install anything extra on AS400.If you directly run SQLCMD from Windows command prompt, it should give you error message to diagnose.[/quote]It would be nice if you remember the year because an Agent Job after an EDI  between SQL Server and AS400 can be payroll transaction so running it with the simple test example may not be relevant to the actual task needed.</description><pubDate>Mon, 04 Mar 2013 17:09:19 GMT</pubDate><dc:creator>Gift Peddie</dc:creator></item><item><title>RE: Execute a sql job from AS400 command line</title><link>http://www.sqlservercentral.com/Forums/Topic1424127-20-1.aspx</link><description>I don't remember exactly what I did with that project years ago.But I am sure that no need to install anything extra on AS400.If you directly run SQLCMD from Windows command prompt, it should give you error message to diagnose.</description><pubDate>Mon, 04 Mar 2013 14:47:59 GMT</pubDate><dc:creator>thsu</dc:creator></item><item><title>RE: Execute a sql job from AS400 command line</title><link>http://www.sqlservercentral.com/Forums/Topic1424127-20-1.aspx</link><description>When we run the command we get the .txt on the SQL server but it is empty.If we try to run RMTCMD to just do a regular copy file from one folder to the other it is working.  However as soon as we do SQLCMD.  It doesn't work.  We tried doing a sql command just to run a select * from table and this doesn't work.  Is there something that needs to be installed on the AS400 or some rights that I am not aware of.</description><pubDate>Fri, 01 Mar 2013 09:27:22 GMT</pubDate><dc:creator>vconlan</dc:creator></item><item><title>RE: Execute a sql job from AS400 command line</title><link>http://www.sqlservercentral.com/Forums/Topic1424127-20-1.aspx</link><description>Thanks I will see how this works.</description><pubDate>Thu, 28 Feb 2013 12:49:32 GMT</pubDate><dc:creator>vconlan</dc:creator></item><item><title>RE: Execute a sql job from AS400 command line</title><link>http://www.sqlservercentral.com/Forums/Topic1424127-20-1.aspx</link><description>Here is my example:RUNRMTCMD CMD('sqlcmd.exe -S "MY-SQL-SERVER" -Q "execute msd              b.dbo.sp_start_job @job_name = ''TestOnly'' "               &amp;gt;&amp;gt; C:\temp\temp.txt')                                   RMTLOCNAME('MYPC.THSU.COM' *IP)                             RMTUSER('thsu')                                             RMTPWD('mypassword')                              Results in temp.txt:Job 'TestOnly' started successfully.TestOnly job history showed "The job succeed"Hope this helps.BTW, I use Windows Authentication in SQL server.-Tom</description><pubDate>Thu, 28 Feb 2013 12:44:40 GMT</pubDate><dc:creator>thsu</dc:creator></item><item><title>RE: Execute a sql job from AS400 command line</title><link>http://www.sqlservercentral.com/Forums/Topic1424127-20-1.aspx</link><description>[quote][b]thsu (2/28/2013)[/b][hr]You can add &amp;gt;&amp;gt; c:\temp.txt to redirect the command output to check if the job started successfully.Also make sure the user is a member of SQLAgent*Role in msdb.[/quote]That will not work for IBM AS400 because since 2005 admin permissions in both IBM and Microsoft is required for most automation solutions to work.</description><pubDate>Thu, 28 Feb 2013 11:12:57 GMT</pubDate><dc:creator>Gift Peddie</dc:creator></item><item><title>RE: Execute a sql job from AS400 command line</title><link>http://www.sqlservercentral.com/Forums/Topic1424127-20-1.aspx</link><description>In fact, you can try to directly run the command on the server (your RUNRMTCMD destination) to see if it starts the SQL job.</description><pubDate>Thu, 28 Feb 2013 10:25:49 GMT</pubDate><dc:creator>thsu</dc:creator></item><item><title>RE: Execute a sql job from AS400 command line</title><link>http://www.sqlservercentral.com/Forums/Topic1424127-20-1.aspx</link><description>I'm sorry I am confused.I need to initiate this on the aS400.  I am trying to use this command.  Does this command not work?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)</description><pubDate>Thu, 28 Feb 2013 10:14:10 GMT</pubDate><dc:creator>vconlan</dc:creator></item><item><title>RE: Execute a sql job from AS400 command line</title><link>http://www.sqlservercentral.com/Forums/Topic1424127-20-1.aspx</link><description>You can add &amp;gt;&amp;gt; c:\temp.txt to redirect the command output to check if the job started successfully.Also make sure the user is a member of SQLAgent*Role in msdb.</description><pubDate>Thu, 28 Feb 2013 10:07:19 GMT</pubDate><dc:creator>thsu</dc:creator></item><item><title>RE: Execute a sql job from AS400 command line</title><link>http://www.sqlservercentral.com/Forums/Topic1424127-20-1.aspx</link><description>[quote][b]vconlan (2/27/2013)[/b][hr]I have and EDI process on my AS400 and at the end of that process I need to call a sql job.  However we can't get it to work.[/quote]Then you can create SSIS package that can run both or create a job steps that runs both.</description><pubDate>Wed, 27 Feb 2013 11:21:24 GMT</pubDate><dc:creator>Gift Peddie</dc:creator></item><item><title>RE: Execute a sql job from AS400 command line</title><link>http://www.sqlservercentral.com/Forums/Topic1424127-20-1.aspx</link><description>I have and EDI process on my AS400 and at the end of that process I need to call a sql job.  However we can't get it to work.</description><pubDate>Wed, 27 Feb 2013 11:01:25 GMT</pubDate><dc:creator>vconlan</dc:creator></item><item><title>RE: Execute a sql job from AS400 command line</title><link>http://www.sqlservercentral.com/Forums/Topic1424127-20-1.aspx</link><description>[quote][b]vconlan (2/26/2013)[/b][hr]I am trying to use this command to execute a sql job from an AS400 command line.  I am having trouble getting it to work.  It doesn't say that the job started.  It just says 'The remote command has produced no output'.                                                              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)[/quote]I have not used it for a while but you can use stored procedure to execute the job but admin permission is required for both SQL Server and AS400.</description><pubDate>Wed, 27 Feb 2013 10:45:42 GMT</pubDate><dc:creator>Gift Peddie</dc:creator></item><item><title>Execute a sql job from AS400 command line</title><link>http://www.sqlservercentral.com/Forums/Topic1424127-20-1.aspx</link><description>I am trying to use this command to execute a sql job from an AS400 command line.  I am having trouble getting it to work.  It doesn't say that the job started.  It just says 'The remote command has produced no output'.                                                              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)</description><pubDate>Tue, 26 Feb 2013 08:58:48 GMT</pubDate><dc:creator>vconlan</dc:creator></item></channel></rss>