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

"James K. Lowden" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.