Home All Groups Group Topic Archive Search About

BCP different behaviour, v7 vs v2005, NULL=space

Author
1 Nov 2007 11:59 AM
PhilHibbs
Similar to my earlier SQLCMD/OSQL question, I have some BCP commands
that I need to run on SQL Server 7. The command produces pipe-
delimited output, but that's just an override on the separator
character, and in SQL Server 7 <NULL> values come out as a single
space, whereas in SQL Server 2005 they come out as an empty value. It
turns out that this isn't a problem as the system that receives the
data trims trailing spaces anyway, but I'd like to know if there is a
way to tidy this up.

My commands look a little like this:

bcp %database%..%table% out %table%.txt -c -t"|" -U %user% -P %pw%

I have tried the -k "keep NULL values" parameter but this makes no
difference.

Phil Hibbs.

Author
1 Nov 2007 10:45 PM
Erland Sommarskog
PhilHibbs (sna***@gmail.com) writes:
Show quote
> Similar to my earlier SQLCMD/OSQL question, I have some BCP commands
> that I need to run on SQL Server 7. The command produces pipe-
> delimited output, but that's just an override on the separator
> character, and in SQL Server 7 <NULL> values come out as a single
> space, whereas in SQL Server 2005 they come out as an empty value. It
> turns out that this isn't a problem as the system that receives the
> data trims trailing spaces anyway, but I'd like to know if there is a
> way to tidy this up.
>
> My commands look a little like this:
>
> bcp %database%..%table% out %table%.txt -c -t"|" -U %user% -P %pw%
>
> I have tried the -k "keep NULL values" parameter but this makes no
> difference.

Hm, I was not able to repeat this on my SQL 7 machine (a virtual box,
if anyone wonders). Which service pack level is SQL 7 on? (Try "bcp -v").


--
Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

AddThis Social Bookmark Button