I need to get files from SFTP and stored them on server. Is there any way I can do that using TSQL or SQL Server Agent? I do not want to use Third party tools or SSIS or PowerShell Script or WinSCP.
First install WinSCP. In my environment it is on the SQL Server we are frequently sending from.
Then you need to create a text file that script the commands. The inside of this file will look like
option batch abort
option confirm off
open sftp://Username:Password@someftp.someftp.com -hostkey="ssh-rsa 2048 29:fd:bb:27:3z:f0:28:b0:58:8g:07:59:b8:21:19:c4"
put D:\exports\*.csv
exit
For more information on WinSCP Scripting you can go HERE
Next create a job and in the step make it type Operating system (CmdExec)
. In the command section call the location of Winscp.exe and pass as an argument the path to the script file you made in the previous step.
C:\Program Files (x86)\WinSCP\WinSCP.exe /script=d:\exports\sftp.txt
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.