I have the following file placed directly in the C drive on my SQL server:
The job is configured as below
But when i run the job it just loops and loops. If I run the file manually it works perfectly. What am I doing wrong?
I had the same issue. I did resolve it by using below command and giving permissions to the .bat file for this user NT Service\SQLSERVERAGENT
cmd.exe /c E:\tools\test.bat
Related
I have a need to add a step (a batch file that needs to run on the application server) once my backup from db server is complete. I am thinking of using the PsEXEC. For whatever reason the command I am testing via the query window executes the batch file at the app server just fine but when I add the same command as step in SQL server agent job it is giving me the error "The process could not be created for step 1 of job 0x318474904D93B54A81BA8B1AEE891A13 (reason: The system cannot find the file specified). The step failed."
Here is the command line running just fine from the query window
EXEC XP_CMDShell 'psexec -accepteula -u domain\user -p psswordhere \appserverip -s -d cmd.exe /c "F:\MovefFilesTest\TheJob\MoveTest.bat"'
FYI: domain\user is local admin on both servers and the sql service and agent are running under this account. It is also a sysadmin on the sql server itself.
Your help is appreciated.
Also F:\ is a local drive on the app server. I am puzzled why it is working on the query window but not when added as agent job
I have requirement of automating the process of running macros to fill sql tables. I am using a sql server job scheduling agent for this. Here is my macros batch file:
"C:\Program Files\Microsoft Office\root\Office16\MSACCESS.EXE" "C:\Users\stiwari\Documents\access_table.accdb" /x upload
These commands work when executed as a batch file from command prompt and the data moves to SQL db. They also work when executed in windows task scheduler. However this syntax doesn't work when using a cmd job task in SQL server.
I have even enabled proxy credentials still it doesn't work.
I get this error all the time:
The step didn't generate any output. Process Exit Code-1073741502. The step failed.
What can be the reason?
A created a mssql local server group containing all our production server. And now i am planning to automate running the script via batch file, is there a way to connect/run my script in my local server group via batch file?
Yes, you can use the sqlcmd command line utility in your batch file to connect and execute queries and / or SQL script files.
I post this question to the other forums too but still cannot find any solution.
I create SSIS package to send file to SFTP server. It works fine when I execute the package with in the SSIS.
But when I tried to run via SQL agent it keeps on running without sending the file until I stops the job by force.
I add the proxy account too but no solution.
My script to run the package is
option batch on
option confirm off
open sftp://UserName:Password#SFTP server Name :22001 -timeout=240
cd ToAA
option transfer binary
put C:\test29022016.csv
mget *.csv
Exit WinSCP
close
exit
Kindly help to solve this issue
Attached find the SSIS package details:
SQL server credentials:
SQL Process Keeps on Running:
SQL Job:
SQL Credentials:
The only difference between you running the package manually, and the SQL Agent running it as a job, is the account that is running the package. In the first case it is your account, and in the second case, it is the SQL Agent's account.
So if it works in the first case, and not the other, then the problem is that the SQL Agent lacks some permission that you have.
Have your network/security administrator give the SQL Agent all the same permissions you have and it will work.
To find out exactly what permission is missing, try logging into your computer as the SQL Agent's account, and run the package in Visual Studio, and see what error message occurs.
I found a work around and I am using windows task scheduler with the help of batch file to run SSIS.
I am using 2 machine one local and other remote from local I have used SSIS package to execute batch file on remote server using wmi process but my problem is that batch file is executing locally instead of remote
Check out System Internals which was bought by Microsoft in the mid 200X.
I used the psexec command to run remote batch files via VB script. I am sure you can do the same with SSIS.
http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
You need rights of course on the remote machine (RM1) and a local copy of psexec.
psexec \\RM1 cmd
This test code runs a command prompt on the remote machine. Parameters like user/pwd will have to be passed.
Good luck in you coding efforts.