Sending generated XML file via SFTP - sql-server

I've generated an XML file using tsql and I'm wondering if there's any way to send it to a remote server via SFTP. Is there any way to do it without external software? What is the best approach to solve this problem?
Any tips will be greatly appreciated
edit:
I forgot to mention that I need a new copy of the file on the server everyday, so...
I need to generate a new file everyday and then replace the old file on the remote server.
I've tried setting up a JOB that runs a SSIS package and it partly does the job, but the standard package doesn't support SFTP. :(

Managed to solve it using WinSCP & command line task in SSIS as suggested by user
Panagiotis Kanavos

Related

Is there any way to change the SQL Server name in Python code based on the environment?

In my Python script, I established the SQL Server DEV connection and I am calling this script in my SSIS package, so now I want to deploy the project on Production server.
Q: How SQL server connection should be changed to Production from Development automatically/dynamically without editing the script manually? Is there a way that it should get/read Production environment?
Please help me out with this, thank you.
sys.argv and pass it as a command line parameter.
Pull it from an environment variable value os.environ
Read from a config file with configparser
Without any sample code, it's hard to say what the right approach should be but I would favor a command line parameter as that allows you to provide the value from the SSIS package (instead of defining configurations in both SSIS space and python space)

Setup psftp for use in SSIS

I am trying to sftp(SSH) transfer files from a remote server to a local directory in SSIS. I was recommended to use PSFTP.exe to conduct the transfer via a batch file. In debug mode, this works flawlessly, but when deployed to SSIS Catalog, the job stalls at the point to connect and transfer the files. I have no errors from SSIS. The job just freezes. The user set in the job is in the administrator's group. I am missing something. How do I troubleshoot?
Thank you.
Thanks to #Nick.McDermaid, I found out that adding the flag -batch and the key -hostkey aa:bb:cc:........ fixed my problem. for some reason, even though i have the RSA key approved via CMD line, the ssis package did not see the approval, forcing the acceptance. adding the hostkey flag solved the key issue, and the batch flag turned off the interactive setting.

After Deployment SQL Server does not allow folder / file creation within SSIS Script Task

I designed a SSIS package that ensures .CSV file generation into a destination folder using a Script Task component. Everything is ok when I run from the Visual Studio solution but the problems starts to appear right after deployment in SQL Server. The Script Task shows success but no file is generated. If someone please can provide help.
Thanks a lot in advance.
Are you running it through a SQL job? This might be because the SQL Agent account (or whatever account you're running with) might not have Read/Write permissions on that particular directory.

SSIS Permission Issue Flat Files

I recently had to move my files to a new SSIS server. Everything seems to be working except when I try to execute a bulk insert it tells me
(Cannot bulk load because the file "E:\FlatFiles\SSG\apmast.txt" could
not be opened. Operating system error code 21(The device is not
ready.).".
It does this for all my flat files. I found an article saying you need to give the MSSQLSERVER user full control of the files, which I did but this does not seem to fix it. Any other ideas? Do I need to give other files the same permissions? I really don't want to just throw full control around if I don't have to. Thanks
I figured it out, turns out that a bulk insert tells the server to look locally for the text file. I was trying to get SSIS to do a bulk insert of flat files from one server into another sql server on the network. As soon as I put the flatfiles on the remote server it grabbed and used them. This seems like a very odd way for it to work. I would expect it to push the files to the sql server instead of asking the sql server to look for the files locally via a hard path.

Checking a directory contains files or not - tsql

I'm trying to code a mssql job that does something using the files in a specific directory. But I don't know the name of the file / files, they will vary in time.
I've found xp_cmdshell command, but I can not use it because of security reasons
Is there any other way to check directory if it contains txt files or not (and if yes get the names of them) in tsql.
Thanks in advance,
Without access to the xp_ stored procedures, no. The other way would be to create a COM object using sp_OACreate that creates a COM Scripting.FileSystemObject, but again access to this may well be restricted as it's a security issue.
As your describing this as an MSSQL job, I'm assuming this is going to be a scheduled task of some description? If so, your best option is probably going to be creating a standard Windows batch file (.BAT) that's scheduled in SQL Server agent that does the existential checking and passes whatever files are found in to your SQL script via sqlcmd/osql.

Resources