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.
Related
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?
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
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.
How to create a batch file to connect to Remote desktop and launch Microsoft Sql server and run some scripts.
I tried creating a batch file to connect to using
#ECHO OFF
mstsc /v:"SERVERNAME"
But i was not able to pass username and password
Can anyone advise on this.
EDIT
psexec \\remotemachine-u username -p password ipconfig
Above one connects me to the remote machine and prints its Ip details.
Now I am trying to execute SQL script which is in D:\ of remote machine to execute in Microsoft SQL server (connection) in the remote machine.
Is that possible.
You can use MSTSC to create the connection, with credentials (be sure to check the box that says "Allow me to Save Credentials"), then save that information to an .RDP file
After you should be able to launch:
mstsc "MyConnectionFile.rdp"
In the connection configuration, there is also a tab: "Programs / Start the following programs on connection", which should get your scripts going.
In general, the issue is to set up everything via the GUI, save it to an RDP file, and use that file in the future.
I have an SSIS package that pulls some data out of SQL Server into a .csv file, then copies the file to a network location (uses Robocopy). Runs fine as a SQL Agent job. When I use DtExec from my own machine, Robocopy fails with 'Access is denied.'
The same error occurs regardless of which network location I enter. If I use Robocopy to try to copy to a local drive on the server instead, it works fine. DtExec is running as my own account. If I use remote desktop to login to the server (again with my own account) I can access all the network shares, and run Robocopy directly no problem. I am using UNC names throughout - no drive letters anywhere.
Is it possible DtExec is running under some low-privilege account on the server that cannot access any network resources? If so, any ideas on how to work around it?