Skip to Content.
Sympa Menu

freetds - Re: [freetds] freebcp out from MS SQL Server drops spaces [C1]

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] freebcp out from MS SQL Server drops spaces [C1]
  • Date: Mon, 6 Jul 2009 22:33:46 -0400

Cedric ROUVRAIS wrote:
>
>
> We have several views that we use to format files that have to be sent
> to external applications and we have an issue that we have been unable
> to resolve. The Free BCP command drop trailing spaces (or inserts tabs)
> which mucks up the file.
>
> Usually what we do (with Sybase and MS SQL bcp it works just fine), is
>
> bcp dbInstance.dbUser.dbView out formattedFile.dat -c -t"" ...

freebcp as a report writer? Learn something new every day! ;-)

You could modify bcp.c::_bcp_exec_out (line 728). Change the fwrite to
pad character columns with spaces.

bsqldb *almost* does what you want. It puts two spaces between columns,
though. If you use any other delimiter, it doesn't pad character data.

I think what you want is sqsh. The -s option lets you set the column
separator.

You bring up an interesting philosophical point: are trailing spaces data?
IMO, no, they're not, and freebcp is correct not to pad character data.
Evidently the authors of bcp thought otherwise, hence the tiny
incompatibility.

HTH.

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page