Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8083465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:29:12+00:00 2026-06-05T17:29:12+00:00

I am using the below code snippet to FTP simple text files from a

  • 0

I am using the below code snippet to FTP simple text files from a Windows Server 2003 / SQL Server 2005 database to a BULL FTP site and am getting some corruption on the BULL end.

select @cmd = 'ftp -s:' + @workdir + @workfilename
exec master..xp_cmdshell @cmd, NO_OUTPUT

The text file contains SEP490067 but when this is opened on the BULL it appears like this ..S.E.P.4.9.0.0.6.7..

I have seen something like this before when sending files using an SSIS FTP component and switching the IsTransferAscii switch to True fixes the problem. The question I have is doe you have to set another commands line switch in the FTP command above to sent the files using ASCII rather than Binary?

Here is the fully TSQL

USE [JCB_QSmart]
GO
/****** Object:  StoredProcedure [dbo].[FTP_PutFile]    Script Date: 06/14/2012 08:56:55 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[FTP_PutFile]
@FTPServer  varchar(128) ,
@FTPUser    varchar(128) ,
@FTPPWD     varchar(128) ,
@FTPPath    varchar(128) ,
@FTPFileName    varchar(128) ,
@SourcePath varchar(128) ,
@SourceFile varchar(128) ,
@workdir    varchar(128),
    @ShowOutput as bit = 0
as

declare @cmd varchar(1000)
declare @workfilename varchar(128)

    select @workfilename = 'ftpcmd.txt'

    -- deal with special characters for echo commands
    select @FTPServer = replace(replace(replace(@FTPServer, '|', '^|'),'<','^<'),'>','^>')
    select @FTPUser = replace(replace(replace(@FTPUser, '|', '^|'),'<','^<'),'>','^>')
    select @FTPPWD = replace(replace(replace(@FTPPWD, '|', '^|'),'<','^<'),'>','^>')
    select @FTPPath = replace(replace(replace(@FTPPath, '|', '^|'),'<','^<'),'>','^>')

    select  @cmd = 'echo '                  + 'open ' + @FTPServer
            + ' > ' + @workdir + @workfilename
    exec master..xp_cmdshell @cmd
    select  @cmd = 'echo '                  + @FTPUser
            + '>> ' + @workdir + @workfilename
    exec master..xp_cmdshell @cmd
    select  @cmd = 'echo '                  + @FTPPWD
            + '>> ' + @workdir + @workfilename
    exec master..xp_cmdshell @cmd
    select  @cmd = 'echo '                  + 'put ' + @SourcePath + @SourceFile + ' ' + @FTPPath + @FTPFileName
            + ' >> ' + @workdir + @workfilename
    exec master..xp_cmdshell @cmd
    select  @cmd = 'echo '                  + 'quit'
            + ' >> ' + @workdir + @workfilename
    exec master..xp_cmdshell @cmd

    select @cmd = 'ftp -s:' + @workdir + @workfilename

    create table #a (id int identity(1,1), s varchar(1000))
    insert #a
    exec master..xp_cmdshell @cmd, NO_OUTPUT

    select id, ouputtmp = s from #a
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T17:29:13+00:00Added an answer on June 5, 2026 at 5:29 pm

    Since you use the -s switch for ftp you should put the ascii-command in your workfile right after you connected to the FTP server.

    EDIT:

    So in your StoredProc you have to add the following line right before the line that contains the 'put ' command:

    select  @cmd = 'echo ' + 'ascii > ' + @workdir + @workfilename
    exec master..xp_cmdshell @cmd
    

    Code should include additional >

    select  @cmd = 'echo ' + 'ascii >> ' + @workdir + @workfilename
    exec master..xp_cmdshell @cmd
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been using the below sample code snippet to update a SQL Server 2005
Below is my code snippet: string ApplPath = Server.MapPath(./); switch (ddlReportType.Text) { case District-wise:
I am deleting all data from the table by using below code snippet NSString
i am using below code to change the the font type of text view.
I am using below code for Embed MP3 Audio Files In Web Pages, <embed
I am actually having a list of text boxes. I am using below code
I have created a tab-pane using HAML as shown in my code snippet below
I have the code snippet below in C++ which basically calculates the pi using
I'm using the code snippet below to create a JFormattedTextField. When entering values via
i am trying to implement curl effect by using below code snippet curl down

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.