Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SP results to ftp

Author  Topic 

Dmh188
Starting Member

37 Posts

Posted - 2012-01-05 : 14:14:43
hey guys,
so i am trying to get results of a stored procedure to save to a file that is FTP to my site. I have on idea how to do this. haha. i tried a batch file and came up with this:
"sqlcmd -U un -P pw -d databse -S Serve -Q"creditmemoreturns" -o ofile.csv"

This does save it as a csv file (havent specified a file path yet) but a few problems. First being it is not delimiting it by a comma like i want it to.. second i do not know how to then have the file sent through ftp.

any help?

X002548
Not Just a Number

15586 Posts

Posted - 2012-01-05 : 15:01:01
-o is just the results of the batch

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

Dmh188
Starting Member

37 Posts

Posted - 2012-01-05 : 15:05:16
when i run the batch as is it will save the results of the query in a csv file. Only problem is that csv is not comma seperated like i need it to be.. I could probably, once that issue is fixed, have a different batch file run to then ftp it where i need it to be.. but i need to results to be saved as a comma delimited file
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-01-05 : 15:08:17
Why don't you use bcp instead?

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

Dmh188
Starting Member

37 Posts

Posted - 2012-01-05 : 15:12:46
I am not familiar with bcp. I just did a google search and it looks promising. Can i use this then to run the results, then i would assume save it on the server, then ftp it out?
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-01-05 : 15:15:22
yes

from command shell

I Assume creditmemoreturns is a query?

bcp 'SELECT * FROM <dbname>.<owner>.<tbname>' queryout c:\output.csv -c -t -T -S<servername>

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

Dmh188
Starting Member

37 Posts

Posted - 2012-01-05 : 15:29:04
creditmemoreturns is a stored procedure, would i just put it in single qoutes? and also is there a way to have this run automatically on a schedule
Go to Top of Page
   

- Advertisement -