Write query results in tab delimited file and push the file to ftp

  • Hi,

    How do I Write query results in tab delimited file and push the file to ftp on daily basis as a sql agent job.

    Thanks.

  • Sounds like a simple SSIS package just waiting to be written ...

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Use Bcp Utility for this,

    create your format file without mentioning -t in format file

    Thanks & Regards,

    Prashant Avhad

  • prashavhad (5/31/2011)


    Use Bcp Utility for this,

    create your format file without mentioning -t in format file

    Thanks & Regards,

    Prashant Avhad

    How does this solution address the ftp requirement?

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Hi Prashavhad,

    Can you please give me more hint on creating bcp for this?

    Thanks

  • ramadesai108 (5/31/2011)


    Hi Prashavhad,

    Can you please give me more hint on creating bcp for this?

    Thanks

    Here's the very best link for this : http://tinyurl.com/3tblqmu

  • Why is this not working?

    DECLARE @exe nvarchar(4000)

    SET @exe =N'bcp '

    SET @exe =@exe + N'

    "SELECT * FROM Customers" '

    SET @exe = @exe + N'queryout c:\test\CustomerInfo.xls -c, -T –S ' + @@SERVERNAME

    EXEC master..xp_cmdshell @exe

    Thanks.

  • I missed to include "exec" in the previous statement

    Why is this not working?

    DECLARE @exe nvarchar(4000)

    SET @exe =N'bcp exec '

    SET @exe =@exe + N'

    "SELECT * FROM Customers" '

    SET @exe = @exe + N'queryout c:\test\CustomerInfo.xls -c, -T –S ' + @@SERVERNAME

    EXEC master..xp_cmdshell @exe

    Thanks.

  • Yet another mistake correced from the previous statement

    Why is this not working?

    DECLARE @exe nvarchar(4000)

    SET @exe =N'bcp '

    SET @exe =@exe + N'

    "EXEC SELECT * FROM Customers" '

    SET @exe = @exe + N'queryout c:\test\CustomerInfo.xls -c, -T –S ' + @@SERVERNAME

    EXEC master..xp_cmdshell @exe

    Thanks.

  • What error are you getting or what is wrong with the output?

  • The problem was that I was having a line break within my select statement. I have it working now. Only thing that I need to do is to add column headers.

    Thanks.

  • Did you manage to automate the FTP part? How did you do it?

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • I do not know how to ftp using cmdshell, so I wrote a webservice in .Net. Do you know a way to use cmdshell for ftp?

    Thanks.

Viewing 13 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic. Login to reply