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
 General SQL Server Forums
 New to SQL Server Programming
 Error bulk loading CSV file with " quotes

Author  Topic 

AnilKumar
Starting Member

2 Posts

Posted - 2008-06-16 : 13:27:02
Hi,

I have a csv file with 1.8 million records. Few of the text columns in each row has commas(,) in them and hence those columns are enclosed by " ".

An example record would look like:
123,abc,"abc, city, state",222,...

Now, the 3rd column should be read as: abc, city, state
But, it is reading ("abc) into 3rd column, and (city) into 4th column and (state") into 4th column resulting in data errors.

Is there a way to specify that fields are optionally enclosed by " as we do in Oracle?

Thanks,
Anil


visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-16 : 13:31:36
Try using bcp after specifying a format file

http://www.nigelrivett.net/SQLTsql/BCP_quoted_CSV_Format_file.html
Go to Top of Page

AnilKumar
Starting Member

2 Posts

Posted - 2008-06-16 : 13:59:19
Thanks for the suggestion. Is there an other way to load without creating format file? I have 600 columns and some columns in the middle of these 600 are quote enclosed. Identifying these quoted columns amongst these 600 columns and writing the format file for these 600 columns is time consuming. I was wondering if there is an easier way to do this.

Thanks,
Anil
Go to Top of Page
   

- Advertisement -