Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 BCP Inconcistency while exporting CSV

Author  Topic 

emmanueloren
Starting Member

2 Posts

Posted - 2012-06-22 : 09:19:11
I have a problem using BCP. The request and the exported file doesn’t have the same number of lines.
This is the command I use :
Exec master..xp_cmdshell 'bcp "SELECT [email],[title],[firstname],[lastname],[dateofbirth],[zip],''RS'' as raison_soc   FROM […]" queryout "C:\Export\20120611003-0.csv" -c -T -CRAW '


The request executed out of BCP returns 6 695 695 lines.
BCP execution output is:



So the right number of lines is supposed to be returned.
The output file contains 6 911 814 lines, 216 119 added lines. None of them is doubled.
Versions:
SQL server 2008
Bcp version 10.0.5500.0

Does anybody got any clue because I haven't...

Thank you in advance for any input.

Emmanuel OREN

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-06-22 : 23:05:50
may be one of involved column has text data which includes carriage return/line breaks

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

emmanueloren
Starting Member

2 Posts

Posted - 2012-06-26 : 08:50:07
Thank you for the idea, in fact there ara NULL caracters interpreted as line breaks !

Emmanuel ORE?
Go to Top of Page

Bill_C
Constraint Violating Yak Guru

299 Posts

Posted - 2012-06-28 : 00:58:05
We regularly have to deal with csv files and have to 'clean' them, removing/replacing comma's from text fields, and many other characters to get them through the import.
Then when they are imported to the tables we do a reverse operation, puting them back in so the records look like their originals, it can be a bit of a pain.
Go to Top of Page
   

- Advertisement -