Solved

Stored Procedure to write a file to an FTP site

Posted on 2014-12-23
1
149 Views
Last Modified: 2015-02-20
Hi there,
is it possible to have a stored procedure to write the result of a query to an FTP site?

Lets said for instance select * from mytable where id =1

Than i have like 2 returned records and wrap those two records on a txt file and upload to an FTP site.
Is this possible and if it is can you point me to the right direction?
Thanks
0
Comment
Question by:COHFL
1 Comment
 
LVL 18

Accepted Solution

by:
Peter Hutchison earned 500 total points
ID: 40515793
What you can do is write a batch file (.BAT) and use the SqlCmd.exe to run the query and product a result and then use the FTP program to upload the file to the FTP site.
e.g.
SQLCMD -S servername -U user -P pwd -q "query string" -o result.csv
FTP -s:ftp_cmds.txt
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now